Elle Posted July 23, 2009 Share Posted July 23, 2009 Hi I am only starting to learn PHP now and would appreciate some help. A while back I created a form and used a tool to create the PHP script for it. When I test the form online, it works most of the time but nevertheless it frequently does not submit the information. Often I go back and resubmit the same information and then it goes through. I find that I'm more likely to get an error if I have not tested it for at least a few minutes, and also after I cleared my cache. I've searched for a solution but have not been successful and find it quite confusing. Here is my PHP code: <?php // Receiving variables @$pfw_ip= $_SERVER['REMOTE_ADDR']; @$First_name = addslashes($_POST['FirstName']); @$Surname = addslashes($_POST['Surname']); @$Email = addslashes($_POST['Email']); @$Telephone = addslashes($_POST['Telephone']); @$Query = addslashes($_POST['Query']); @$Discovery_status = addslashes($_POST['DiscoveryStatus']); // Validation if (strlen($First_name) == 0 ) { header("Location: contact-error.html"); exit; } if (strlen($Surname) == 0 ) { header("Location: contact-error.html"); exit; } if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email)) { header("Location: contact-error.html"); exit; } if (strlen($Email) == 0 ) { header("Location: contact-error.html"); exit; } if (strlen($Telephone) == 0 ) { header("Location: contact-error.html"); exit; } if (strlen($Query) == 0 ) { header("Location: contact-error.html"); exit; } if (strlen($Discovery_status) == 0 ) { header("Location: contact-error.html"); exit; } //Sending Email to form owner $pfw_header = "From: $Email\n" . "Reply-To: $Email\n"; $pfw_subject = "Website Contact Enquiry"; $pfw_email_to = "elzet@wsiwebmarketing.co.za"; $pfw_message = "Visitor's IP: $pfw_ip\n" . "First_name: $First_name\n" . "Surname: $Surname\n" . "Email: $Email\n" . "Telephone: $Telephone\n" . "Query: $Query\n" . "Discovery_status: $Discovery_status\n"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; header("Location: contact-thanks.html"); ?> Thanks! EDIT: Please use [code][/code] tags when posting code on the forums! Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted July 23, 2009 Share Posted July 23, 2009 the @ sign stops any errors from reporting. I would remove the @'s and turn on error reporting for that page with this at the top ini_set("display_errors","1"); ERROR_REPORTING(E_ALL); that will then let you know if there's any errors. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.