Error 500 PHP

bjyoung

Junior Member
Jul 23, 2013
1
0
0
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";
}
?>
 

Tweak155

Lifer
Sep 23, 2003
11,449
264
126
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.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
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.
 

SecurityTheatre

Senior member
Aug 14, 2011
672
0
0
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.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,723
4,686
75
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.
 

uclabachelor

Senior member
Nov 9, 2009
448
0
71
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?