PHP scripts displays blank screen

Hi,

I’m new here and new to PHP.
I have created a script to send form data by e-mail, i have uploaded the script to the hosting server (network solutions) but when i fill out the form and submit it it just displays a blank screen.

here is my script

<?php $errors = ''; $myemail = '[email protected]';//<----- Put your email address here. if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['course_location']) || empty($_POST['address'])) { $errors .= "\n Error: all fields are required"; } $name = $_POST['name']; $email = $_POST['email']; $course_location = $_POST['course_location']; $address = $_POST['address']; if (!preg_match( "~^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.a-z0-9-]+)*(\.[a-z]{a-z})$/i~",$email)) { $errors .= "\.n Error: Invalid email address"; } if( empty($errors)) { $to = $myemail; $email_subject = "Booking form submission: $name"; $email_body = "You have received a new booking.". " Here are the details:\n Name: $name \n ". "Email: $email\n Course Location \n $course_location Address \n $address"; $headers = "From: [email protected]"; $headers .= "Reply-To: $email"; mail($to,$email_subject,$email_body,$headers); //redirect to 'thank you' page header("Location: http://high-flyerz.com/booking_form_thank_you.html"); } ?>

I think this is what you’re trying to accomplish?
[php]

<?php $errors = ''; $myemail = '[email protected]';//<----- Put your email address here. if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['course_location']) || empty($_POST['address'])){ $errors .= "\n Error: all fields are required"; } $name = $_POST['name']; $email = $_POST['email']; $course_location = $_POST['course_location']; $address = $_POST['address']; if (!preg_match("@[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*\@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\[email protected]",$email)) { $errors .= "\.n Error: Invalid email address"; } if( empty($errors)) { $to = $myemail; $email_subject = "Booking form submission: $name"; $email_body = "You have received a new booking.". " Here are the details:\n Name: $name \n ". "Email: $email\n Course Location \n $course_location Address \n $address"; $headers = "From: [email protected]"; $headers .= "Reply-To: $email"; mail($to,$email_subject,$email_body,$headers); //redirect to 'thank you' page header("Location: http://high-flyerz.com/booking_form_thank_you.html"); } else { echo $errors; } ?>[/php]

It didn’t like the long if statement on broken lines, and you weren’t outputting anything if the information was erroneous. I got the regexp from http://www.regular-expressions.info/email.html

Hope this helps! =]

Thanks i will give this a try.

Sponsor our Newsletter | Privacy Policy | Terms of Service