Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Halifax, Nova Scotia, Canada
    Thanked 0 Times in 0 Posts

    Exclamation Very Simple Contact Form Problem... Probably a 2 minute solution! Help Appreciated.


    I am just trying to get the simplest possible contact form running for my friend's charity site, and then I am going to add reCapcha to prevent spam. I know there are more concerns to worry about, but honestly, this site won't get much traffic.

    Anyway, it's been a while since I did any of this, and whenever I try to use the form it generates an error claiming I haven't entered my e-mail address even when I have. Please tell me what's up. Here's the mailer.php code:

    //variables (change these)
    $youremail = "fakey@fake.com";
    // your email address
    $subject = "Mi Camera, Mi Mundo Web Message";
    // the subject of the email
    $thankyou = "thankyou.html";
    // thank you page
    // don't change anything else
    ;if($email == ""){
    No email address added. Please go back.<br/>
    ;}elseif($name == ""){
    No name added. Please go back.<br/>
    }elseif($message == ""){
    No message added. Please go back.<br/>
    $msg = ereg_replace("\\\'", "'", $message);
    $msg = ereg_replace('\\\"', "\"", $msg);
    $message1 = "from: $name\nemail: $email\nmessage:\n$msg1";
    mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
    <meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
    And the form code for the page is as follows:
    <div id="contactform">
    				<form action="mailer.php" method="post">
    					<legend>Required Information</legend>
    					<label for="name">Name</label>
    					<input id="name" name="name" type="text"><br/> 
    					<label for="email">Email addess</label>
    					<input id ="email" name="email" type="text"><br/>
    					<label for="message">Message</label>
    					<textarea id="message" name="message" cols="40" rows="5"></textarea><br/>
    					<input class ="submit" type="submit" value="Send Message"><br/>
    I know that any seasoned eye can probably solve this problem in 2 minutes so I implore you to help us all out.

    Thanks to all those who attempt/respond.

    Once I thought I was wrong but I was mistaken.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Denver, Colorado USA
    Thanked 340 Times in 332 Posts
    The code is dependent on an old depreciated and soon to be completely removed php feature, register_globals.

    You need to reference the form data using $_POST variables, i.e. $_POST['email'] instead of $email

    If you add the following two lines of code immediately after your first opening <?php tag, you will see all the php detected errors -

    PHP Code:
    The "undefined" variable messages indicate the program variables that you will need to change.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


    Posting Permissions

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