Page 1 of 1

Using php to email from html form - email is sent but empty

Posted: Wed Jan 21, 2009 11:59 am
by hopper_b
Hi - I am new here and to php. I am using it to send a very simple email from an html contact form. It is hosted on a web server that I have no access to and the hosting company doesn't seem to know what to configure or how. I've tested the code on 2 other Linux servers and it works perfectly - testing on the server it is supposed to be hosted on generates an empty email. Any thoughts as to why the email gets sent without errors, but is empty, but works fine as is on a different server? Below is the php code - all values are being passed properly. Any suggestions would be greatly appreciated. You'll have to be very specific as my knowledge of php is limited. Thanks so much. The problematic server is running php 5.0 but that is all the info I have.

Code: Select all

 
<?php
 
$name = $first_name." ".$last_name;
$street = $address;
$address = $city.", ".$state." ".$zip_code;
$from = "mhaines@haineselectric.com";
$time = $when_to_call;
$comments =  $additional_comments;
$subject = "Customer Service Request from Website";
$email = $email_address;
$pPhone = $day_phone_area."-".$day_phone_exchange."-".$day_phone_number;
$aPhone = $evening_phone_area."-".$evening_phone_exchange."-".$evening_phone_number;
 
$to = "service@haineselectric.com";
 
$contents = "Customer Service Request from Website: \n\n".$name."\n".$street."\n".$address."\n\n".$email."\n\nDay Phone: ".$pPhone."\nEvening Phone: ".$aPhone."\n\nBest Time to Call: ".$time."\nAdditional Comments: ".$comments;
 
 
mail($to, $subject, $contents);
 
header("Location: http://www.haineselectric.com/thankyou.html");
 
?>

Re: Using php to email from html form - email is sent but empty

Posted: Wed Jan 21, 2009 12:06 pm
by Burrito
please use PHP tags when posting code in the forums.

try using the POST[] array as register globals is probably turned off on the server.

Re: Using php to email from html form - email is sent but empty

Posted: Wed Jan 21, 2009 12:19 pm
by hopper_b
Sorry about the tags. I even read the suggestions and still missed that. I will do some searching for using the post array - so new to this. Would Register Globals be something that can be changed in the php.ini file on the server? Thanks for your help.

Re: Using php to email from html form - email is sent but empty

Posted: Wed Jan 21, 2009 12:21 pm
by Burrito
hopper_b wrote:...Would Register Globals be something that can be changed in the php.ini file on the server? Thanks for your help.
yes, but you should leave them off for safety's sake.

Re: Using php to email from html form - email is sent but empty

Posted: Thu Jan 22, 2009 4:33 pm
by hopper_b
sorry - can you provide an example?

Re: Using php to email from html form - email is sent but empty

Posted: Thu Jan 22, 2009 5:09 pm
by hopper_b
I figured it out and you were right. Thank you so much!