• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Error 500 PHP

bjyoung

Junior Member
Hi, I've just started learning PHP and I have a bit of a learning curve with error 500. Does any one mind pointing me in the right direction (other than google) thanks in advance! 🙂

<?php

$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$phone = stripslashes($_POST['phone']);
$catsname = stripslashes($_POST['catsname']);
$datefrom = $_POST['datefrom'];
$dateto = $_POST['dateto'];
$message = stripslashes($_POST['message']);
$form_message = "Name: $name \nEmail: $email \nPhone: $phone \nCats Name: $catsname \nDate From: $datefrom \nDate To: $dateto \nBooking: $message";



mail("XXXXXXXX@live.com", "Email Subject", $form_message, "From: $email" );

header ('Location: http://www.xxxxxx.com.html');
exit ();

if($send_contact){
echo "We've received your contact information";
}
else {
echo "ERROR";
}
?>
 
I haven't done PHP in a long time, but you can't just shove variables in strings. Need something like:

$phpVar = $strHello . " " . $strWorld;

I only did PHP for a few months and it was some years ago. But I don't think this is the cause of your problem. Try commenting out the mail function and see if the page loads. Also it could be because I don't see $send_contact defined anywhere either, but it could be in a header / included file. Not sure if that causes a null error.
 
Actually you can -- double quotes strings process both \n escape codes and $v variables names. $message = "Dear $person, bla bla"; is valid PHP.

About the 500 error, no idea. mail() might not be set up or the data you are passing it might be invalid.

Comment out the mail line and add an echo to see what you are sending to mail.
 
Are you successfully invoking the mail function? What happens if you comment it out?

your location in the header is weird. http://www.xxxxxx.com.html really? (assuming you only replaced the DNS name with xxxxx, why the .html?)

Also, your echo commands do nothing. In fact they never run, because "header location" sends the browser off to a different page entirely, dropping any display after that point.
 
What you need to do is find your web server's log file. Potentially, /var/www/log/error_log, /var/log/apache2/error.log, or something like that. The logfile usually gives a line number and more informative error code.
 
Hi, I've just started learning PHP and I have a bit of a learning curve with error 500. Does any one mind pointing me in the right direction (other than google) thanks in advance! 🙂

<?php

$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$phone = stripslashes($_POST['phone']);
$catsname = stripslashes($_POST['catsname']);
$datefrom = $_POST['datefrom'];
$dateto = $_POST['dateto'];
$message = stripslashes($_POST['message']);
$form_message = "Name: $name \nEmail: $email \nPhone: $phone \nCats Name: $catsname \nDate From: $datefrom \nDate To: $dateto \nBooking: $message";



mail("XXXXXXXX@live.com", "Email Subject", $form_message, "From: $email" );

header ('Location: http://www.xxxxxx.com.html');
exit ();

if($send_contact){
echo "We've received your contact information";
}
else {
echo "ERROR";
}
?>

Error 500 is an internal server error, usually meaning the server is misconfigured, or doesn't know how to to handle a request.

I don't see anything syntactically wrong with the code you posted, but the header() to location is what's probably giving you the error.

Have you tried accessing http://www.xxxxxx.com.html manually?
 
Back
Top