Hi, I have a form on this page - http://www.organicspirit.co.uk/contact.php using the script called "send_contact.php" when submitted. It used to work but now when you hit submit, you get following message - 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. Do I need to understand that the issue lies with the hosting provider or is there something wrong with my script (which I pasted below) send_contact.php --------------------------------------- <?php // Contact subject $subject = $_POST['subject']; // Details $message = $_POST['detail']; // Mail of sender $mail_from = $_POST['customer_mail']; // From $header = "from: $name <$mail_from>"; // Enter your email address $to = 'info@organicspirit.co.uk'; $send_contact = mail($to,$subject,$message,$header); // Check, if message sent to your email header ('Location: http://www.organicspirit.co.uk/thank-you.html'); exit (); if($send_contact){ echo "We've received your contact information"; } else { echo "ERROR"; } ?> Thank you for your help! P
What does the server log say? Is the email still being sent? $name is null but that shouldn't be the problem. Headers should end with a newline and are case sensitive so try using $header = "From: $name <$mail_from> \r\n"; PHP: Some hosting companies require using the -f parameter so if that doesn't work try $send_contact = mail($to,$subject,$message,$header,'-finfo@organicspirit.co.uk'); PHP: Hope that helps, Cheers!
I think you may get error like Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\xampp\htdocs\test\head.php:12) in D:\Program Files\xampp\htdocs\test\head.php on line 15 The reason is you have already set the header to redirect the page using "header(location:...)" after setting this you are trying to do echo. Just commend the echo statement it will work
Thanks vinoth.t. I am not sure what you mean (because I am useless at php) by commend the echo statement I am afraid. Do you mean 'command' or 'comment'? And could you maybe paste how the script should read? Thanks again!
Thanks vinoth.t. I tried two options but still got the 500 error. Here below is what I tried - <?php // Contact subject $subject = $_POST['subject']; // Details $message = $_POST['detail']; // Mail of sender $mail_from = $_POST['customer_mail']; // From $header = "from: $name <$mail_from>"; // Enter your email address $to = 'pierrick419@hotmail.com'; $send_contact = mail($to,$subject,$message,$header); // Check, if message sent to your email if($send_contact){ echo "We've received your contact information"; } else { echo "ERROR"; } ?> ---------------------------------------------------- <?php // Contact subject $subject = $_POST['subject']; // Details $message = $_POST['detail']; // Mail of sender $mail_from = $_POST['customer_mail']; // From $header = "from: $name <$mail_from>"; // Enter your email address $to = 'info@organicspirit.co.uk'; $send_contact = mail($to,$subject,$message,$header); // Check, if message sent to your email header ('Location: http://www.organicspirit.co.uk/thank-you.html'); exit (); else { echo "ERROR"; } ?> Help! P
You could check that there's no hidden space or white space before the first <?php in the file. A php file must start with <?php Then I think vinoth meant to try with the end of the script looking like this: if($send_contact){ //echo "We've received your contact information"; } else { //echo "ERROR"; } ?>
The second one definitely won't work, since it has an else statement without an if. But you stated in your original post that it used to work but now doesn't. If it just stopped working and you didn't make any changes, then possibly the host has made some changes to the server so you might check with them.