I've set up a simple online voting form (HTML) where the user pushes the submit button and it calls up a PHP script to send the data to my email address.
The issue I'm having is, the form works correctly and the user hits submit..... a 500 Error page appears BUT I receive the email with the data from the form.
I have a redirection code set in my PHP scrip but it obviously isn't working.
In addition to Marks answer, and has more to do with PHP than with IIS; mail() returns TRUE for success and FALSE otherwise. So, something like if(mail($recipient, $subject, $formcontent, $mailheader) !== FALSE) { header("Location: thank_you.html"); } else
{ header("Location: errorpage.html"); } See http://www.php.net/manual/en/function.mail.php for more information and examples.
qld_ombo
2 Posts
IIS7 Contact form PHP script redirect issue
Oct 30, 2012 12:22 AM|LINK
Hi,
I was wondering if someone could help me.
I've set up a simple online voting form (HTML) where the user pushes the submit button and it calls up a PHP script to send the data to my email address.
The issue I'm having is, the form works correctly and the user hits submit..... a 500 Error page appears BUT I receive the email with the data from the form.
I have a redirection code set in my PHP scrip but it obviously isn't working.
Here is the code from my PHP script :
<?php
$name = $_POST['Name'];
$email = $_POST['Email'];
$Nominees = $_POST['Nominees'];
$formcontent = "From: $name \n Vote: $Nominees";
$recipient = my_email@myemail.com;
$subject = "Voting submission";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
header('Location: Thank_You.html');
exit()
?>
Any help would be great as I've been pulling my hair out for 2 days trying to get it to show the redirection page!!!!!!
Thanks
PHP 500 - Internal server error form
Mark - MSFT
167 Posts
Microsoft
Re: IIS7 Contact form PHP script redirect issue
Nov 01, 2012 09:29 AM|LINK
Hi,
Is your project works while in your IDE? And could you post the error details here.
You have the die function, if the mail function is false, then it will print the message and exit the current script. So will be none redirection.
Please try comment die function, and reply.
Best Regards
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
JanReilink
36 Posts
Re: IIS7 Contact form PHP script redirect issue
Nov 09, 2012 05:47 AM|LINK
Vevida Services - worry-free webhosting: http://vevida.com