Results 1 to 2 of 2

Thread: contact form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    contact form

    Hi all, I have a contact form I got off the net. It is the following:

    Code:
    <html>
    <head>
    <title>Contact Us Form</title>
    </head>
    
    <body>
    
    <?php
    // declare values
    $contact_email = $_POST['EmailAddress'];
    $contact_subject = $_POST['Subject'];
    $contact_name = $_POST['FullName'];
    $contact_message = $_POST['Message'];
    $mydate = date ( 'l, F d Y g:i A',time()+240 );
    
    // where to send e-mail to
    $to = '[email protected]';
    
    // e-mail subject
    $subject = "Message submitted using Contact Us form";
    
    // e-mail message
    $message = "You have received a contact message:\r\n"
    
    ."----------------------------------------------------------------\r\n"
    ."Contact Name: $contact_name\r\n"
    ."Subject: $contact_subject\r\n"
    ."Submitted: $mydate\r\n"
    ."From IP: {$_SERVER['REMOTE_ADDR']}\r\n\r\n"
    ."Message: $contact_message\r\n"
    ."Form Address: {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
    
    $headers = "From: $contact_name <$contact_email>\n"
    ."Reply-To: $contact_email\n"
    ."X-Mailer: PHP/".phpversion();
    
    // check for validation, then send the e-mail
    if(empty($contact_name) || empty($contact_email) || empty($contact_subject) || empty($contact_message)) {
    echo '<p>Send us a message, enter your information below and click \'Submit\'!</p>
    <form method="post" action="">
    <table id="Form-Details">
    <tbody>
    <tr><td>Name:</td><td><input type="text" name="FullName" size="20" /></td>
    <td>Subject:</td><td><input type="text" name="Subject" size="20" /></td></tr>
    <tr><td>Email:</td><td colspan="3"><input type="text" name="EmailAddress" size="20" /></td></tr>
    <tr><td colspan="4">Message:</td></tr>
    <tr><td colspan="4"><textarea rows="6" name="Message" cols="47" class="input"></textarea></td></tr>
    <tr><td colspan="4" class="right1"><input type="submit" value="Submit" /><input type="reset" value="Reset" /></td></tr>
    </tbody>
    </table>
    </form>';
    } elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $contact_email)) {
    echo "<p>ERROR: Please enter a valid e-mail address.</p>";
    } else {
    mail( $to, $subject, $message, $headers );
    echo "<h3>Message Sent!</h3><p>Dear $contact_name,<br /><br />We will get back to you as soon as possible using $contact_email.";
    }
    ?>
    </body>
    </html>
    This code works, but the problem is I want to embed it into my existing html page. I have renamed the .html to .php on my page, and then copied everything between the <?php and ?> (including the <?php and ?>), and when I run it...nothing happens...no email is sent. What causes this? It sends fine from within its own php page...but not mine.
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: contact form

    Don't use the code. I don't know where it came from but it has security issues, could falsly flag valid email addresses as invalid and it is poorly written.

    You should write your own. Create a HTML form and I'll guide you are through the rest of it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width