Page 1 of 1

Problems with Forms after updating server to PHP 5.2.1

Posted: Sat May 05, 2007 3:45 pm
by chriscrooz
Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a contact form for my website that I had my buddy build for me in PHP so it would sent the data to an email account of my liking. Here's the code below, which now does not work with the latest version of PHP that my host updated to (PHP 5.2.1 or 5.2.2). What variables changed that now prevents this form working?

Code: Select all

<?php
//**************************************************************************
//Main PHP Body.  This is the core of the script.

//Get variables from HTTP
$yourname = $_POST['yourname'];
$youremail = $_POST['youremail'];
$foundus = $_POST['foundus'];
$feedback = $_POST['feedback'];

//Ensure all fields have been set
if ($yourname != "" && $youremail != "" && $foundus != "" && $feedback != ""){
  //Check to make sure email address is valid, if not give error and back link
  if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $youremail)) {
    echo "<H4><font color=\"#333333\" size=\"2\" face=\"Verdana, Arial\">Invalid email address.  Please click back and enter a valid email address.</font></H4>";
    echo "<a href='javascript:history.back(1);'>Back</a>";
  }
  else{
    //Construct the email:
    $recipient = "info@whalencreative.com";
    $recipientname = "Creative";
    $subject = "WEBSITE MAIL: " . $foundus . " - ";
    $message = "NAME:           " . $yourname . "\r\n" . "EMAIL:            " . $youremail . "\r\n" . "REQUEST:  " . $foundus . "\r\n\r\n\r\n" . "BODY:" . "\r\n" .
	"-------------------------------------------" . "\r\n" . $feedback;
    $headers = "To: $recipientname <$recipient>\r\n";
    $headers .= "From: $yourname <$youremail>\r\n";
    //Send the email
    if(mail($recipient, $subject, $message, $headers)){
      echo "<H4><font color=\"#333333\" size=\"2\" face=\"Verdana, Arial\">Thank you, <br>Your mail has been sent. Please allow one business day for a response.</font></p>";
    }
    //If email could not be sent, display error
    else{
      echo "<H4><font color=\"#333333\" size=\"2\" face=\"Verdana, Arial\">Due to technical issues, your email could not be sent.  Please try again later</font></H4>";
    }
  }
}
//Display error if somes fields not set
else{
  echo "<H4><font color=\"#333333\" size=\"2\" face=\"Verdana, Arial\">You must enter all fields.  Please click back and enter missing fields.</font></H4>";
  echo "<a href='javascript:history.back(1);'>Back</a>";
}



//*******************************************************************************
?>

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat May 05, 2007 4:22 pm
by Weirdan
what part of the script do not work as you expect it to do?