It just hangs and doesnt execute. I dont understand. Here is my contact.php - The actual html page just blows out all white and it doesnt redirect either.. Any advice? <?php /* Set e-mail recipient */ $myemail = "myemail@yahoo.com"; /* Check all form inputs using check_input function */ $yourname = check_input($_POST['yourname'], "Enter your name"); $email = check_input($_POST['email'], "Write a subject"); $type = check_input($_POST['type']),"Write a type"); $phone = check_input($_POST['phone']),"Write a phone"); $processing = check_input($_POST['processing']),"Write a processing"); $sales = check_input($_POST['sales']),"Write a sales"); $country = check_input($_POST['country']),"Write a country"); $comments = check_input($_POST['comments'], "Write your comments"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: $yourname E-mail: $email Phone: $phone business type: $type country: $country processing: $processing sales volume: $sales Comments: $comments End of message "; /* Send the message using mail() function */ mail($yourname, $email, $type, $phone, $processing, $sales, $country, $comments ); /* Redirect visitor to the thank you page */ header('Location: thanks.htm'); exit(); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> PHP: Appreciate any advice
i guess u didn't had '}' for email check. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } PHP:
Nice catch - I closed it with the } -- but it still doesnt redirect or send an email.. any other suggestions. Freelance get out of my thread - I dont need any paid support.
There are several errors like the ones with the check_input() functions where you put more brackets than needed and the mail() function where I still don't know what you wanted to do. I tried to change them, I hope that catched them all. <?php /* Set e-mail recipient */ $myemail = 'myemail@yahoo.com'; /* Check all form inputs using check_input function */ $yourname = check_input($_POST['yourname'], 'Enter your name'); $email = check_input($_POST['email'], 'Write a subject'); $type = check_input($_POST['type'],'Write a type'); $phone = check_input($_POST['phone'],'Write a phone'); $processing = check_input($_POST['processing'],'Write a processing'); $sales = check_input($_POST['sales'],'Write a sales'); $country = check_input($_POST['country'],'Write a country'); $comments = check_input($_POST['comments'], 'Write your comments'); /* If e-mail is not valid show error message */ if ( !preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email) ) { show_error('E-mail address not valid'); } /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: $yourname E-mail: $email Phone: $phone business type: $type country: $country processing: $processing sales volume: $sales Comments: $comments End of message"; /* Send the message using mail() function */ mail( $myemail, 'Subject of the message', $message, 'From: noreply@example.com'); /* Redirect visitor to the thank you page */ header('Location: thanks.htm'); exit(); /* Functions we used */ function check_input( $data, $problem = '' ) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ( $problem && strlen($data) == 0 ) { show_error($problem); } return $data; } function show_error( $myError ) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> PHP:
to be true Bogi's code is quiet understandable, i didn't even got wat u actually want to do . try that code it shud work
Did you try Bogi's code? And freelance wasn't offering you paid support. He simply asked if the dude's ("arpit") code above his post worked :?
Why don't you just enable errors for the tests? Or put some echo'es to check where the script stops (if its not a code error) ?