Hello all first post and need some help, I need to make up a contact.php for the form i have created on a website, I have a contact.php that works but i`m having a couple of problems with it and wondered if anybody could help me out? This is the code <?php $fullname = $_POST["fullname"]; $businessname = $_POST["businessname"]; $address = $_POST["address"]; $postcode = $_POST["postcode"]; $emailaddress = $_POST["emailaddress"]; $phonenumber = $_POST["phonenumber"]; $verif_box = $_POST["verif_box"]; $to = "info@#####.co.uk"; $subject = " enquiry"; $headers = "From: $emailaddress\n"; $message = "A visitor to your site has filled out the following information.\n Full Name: $fullname business Name: $businessname Company Address: $address Post Code: $postcode Email Address: $emailaddress Phone Number: $phonenumber"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['emailaddress'])) { exit('Invalid Email Address'); } if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ mail($to,$subject,$message,$headers); echo " <html><head><style type=\"text/css\"> h2 { text-align: center; } </style> </head><body> <h2>Verification Matched - Details Sent<h2 /> "; } else { echo " <style type=\"text/css\"> h2 { text-align: center; } </style> </head><body> <h2>Verification Did Not Match - Details NOT Sent<h2 /> </body></html> "; } ?> HTML: The problem is anytime i fill the form without the email filled in it goes to another page with an error instead of somesort of alert of some kind, i`d also like it to go to another webpage once completed like a thankyou page. Is there anyway of doing this? I`m a complete novice when it comes to php and am really struggling with this, I`d really appreciate any help.
change the "exit('Invalid Email Address');" line to "header('Location: errorpage.php');" then change the "echo" line to a header line also and get rid of all that html code.
Hi thanks for the reply, did you mean like this? if (preg_match(' /[\r\n,;\'"]/ ', $_POST['emailaddress'])) { "header('Location: errorpage.php');" } if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){mail($to,$subject,$message,$headers);echo " header("location:http://www.######.co.uk/thankyou.html"); }?> This just comes up with more errors for some reason, have i done it wrong???? Thanks again