#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    PHP email question


    Hi,

    I got an email contact form page on my website, with the following php code:

    PHP Code:
    <?php
    $name 
    $_POST['name'];
    $email $_POST['email'];
    $message $_POST['message'];
    $formcontent=" From: $name \n Message: $message";
    $recipient "elvis@presley.com";
    $subject "Web Mail";
    $mailheader "From: $email \r\n";
    mail($recipient$subject$formcontent$mailheader) or die("Error!");
    $url 'URL ADDRESS!/page_More';
    echo 
    '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>
    Now, it works just fine when sending, but my situation is that apparently people can just press the Send button even if they don't fill everything out.

    Can anyone tell me what the code would be to have all fields required to be filled?

    Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    Sydney Australia
    Posts
    189
    Rep Power
    84
    Test your variables to see that they contain reasonable values. If they don't, return an error, or return to the previous page with an error message, or ..... whatever you want.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    276
    THIS LINK should offer you some direction.
    Last edited by DonR; March 19th, 2013 at 12:57 AM.

IMN logo majestic logo threadwatch logo seochat tools logo