isi Posted December 13, 2008 Share Posted December 13, 2008 Hi there, new to the forum I just set up a godaddy hosting account with PHP5 and migrated my site from Site5, i had this php form working but not it just doesnt send out the email - could this be because of the PHP version? <?php $to = "[email protected]"; $subject = "Email"; $body .= "Name: " . $HTTP_POST_VARS['sender_name'] . "\n"; $body .= "Contact Number: " . $HTTP_POST_VARS['sender_cnum'] . "\n"; $body .= "Address: " . $HTTP_POST_VARS['sender_addy'] . "\n"; $body .= "Post Code: " . $HTTP_POST_VARS['sender_postcode'] . "\n"; $body .= "Reply Email Address: " . $HTTP_POST_VARS['sender_email'] . "\n\n"; $body .= "Event Type: " . $HTTP_POST_VARS['event_type'] . "\n"; $body .= "Venue Address: " . $HTTP_POST_VARS['venue_addy'] . "\n"; $body .= "Venue Post Code: " . $HTTP_POST_VARS['venue_postcode'] . "\n"; $body .= "Event Start Time: " . $HTTP_POST_VARS['event_starttime'] . "\n"; $body .= "Venue Contact Number: " . $HTTP_POST_VARS['venue_cnum'] . "\n\n"; $body .= "Other Requirements: " . $HTTP_POST_VARS['other_requirements'] . "\n"; $body .= "\n\n---------------------------\n"; $body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_email'] . ">\n"; $header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_email'] . ">\n"; $header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_email'] . ">\n"; $header .= "X-Mailer: PHP/" . phpversion() . "\n"; $header .= "X-Priority: 1"; if(@mail($to, $subject, $body, $header)) { echo "output=sent"; } else { echo "output=error"; } ?> Is there something broken in the code? when I execute it is does print "output=sent". Thanks, isi Link to comment https://forums.phpfreaks.com/topic/136774-form-mail-help/ Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Try <?php $to = "[email protected]"; $subject = "Email"; $body .= "Name: " . $_POST['sender_name'] . "\n"; $body .= "Contact Number: " . $_POST['sender_cnum'] . "\n"; $body .= "Address: " . $_POST['sender_addy'] . "\n"; $body .= "Post Code: " . $_POST['sender_postcode'] . "\n"; $body .= "Reply Email Address: " . $_POST['sender_email'] . "\n\n"; $body .= "Event Type: " . $_POST['event_type'] . "\n"; $body .= "Venue Address: " . $_POST['venue_addy'] . "\n"; $body .= "Venue Post Code: " . $_POST['venue_postcode'] . "\n"; $body .= "Event Start Time: " . $_POST['event_starttime'] . "\n"; $body .= "Venue Contact Number: " . $_POST['venue_cnum'] . "\n\n"; $body .= "Other Requirements: " . $_POST['other_requirements'] . "\n"; $body .= "\n\n---------------------------\n"; $body .= "Mail sent by: " . $_POST['sender_name'] . " <" . $_POST['sender_email'] . ">\n"; $header = "From: " . $_POST['sender_name'] . " <" . $_POST['sender_email'] . ">\n"; $header .= "Reply-To: " . $_POST['sender_name'] . " <" . $_POST['sender_email'] . ">\n"; $header .= "X-Mailer: PHP/" . phpversion() . "\n"; $header .= "X-Priority: 1"; if(@mail($to, $subject, $body, $header)) { echo "output=sent"; } else { echo "output=error"; } ?> Link to comment https://forums.phpfreaks.com/topic/136774-form-mail-help/#findComment-714327 Share on other sites More sharing options...
isi Posted December 13, 2008 Author Share Posted December 13, 2008 That works perfectly Wayne, huge thanks!!! What did you fix? Link to comment https://forums.phpfreaks.com/topic/136774-form-mail-help/#findComment-714331 Share on other sites More sharing options...
waynew Posted December 13, 2008 Share Posted December 13, 2008 Basically, $HTTP_POST_VARS is from the stone age. The newer way to go about it is to use $_POST. Same goes for $HTTP_GET_VARS, which should be replaced by $_GET. Link to comment https://forums.phpfreaks.com/topic/136774-form-mail-help/#findComment-714340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.