Jump to content

PHP form - back and bringing the ruckus


chairmanMeow

Recommended Posts

Hi  :D

 

Having thought the PHP form was working OK, I took a break. Upon return, it's up to its old tricks.

 

Could anyone glance over this code for blatant errors?

 

It works when it wants and when it doesn't...

 

Much appreciated  ;D

 

::)

 

 

 

<?

$select=$_POST['select'];

$name=$_POST['name'];

$email=$_POST['email'];

$confirmail=$_POST['confirmail'];

$month=$_POST['month'];

$day=$_POST['day'];

$year=$_POST['year'];

$leaving=$_POST['leaving'];

$hour=$_POST['hour'];

$minutes=$_POST['minutes'];

$ampm=$_POST['ampm'];

$going=$_POST['going'];

$flightnumber=$_POST['flightnumber'];

$pay=$_POST['pay'];

$song=$_POST['song'];

$comments=$_POST['comments'];

$to="[email protected]";

header('Location:http://www.kabeoke.com');

$message="Message Type: $select\n\nName: $name\n\nEmail: $email\n\n$confirmail\n\nDate of Journey: $month, $day, $year\n\nLeaving From: $leaving\n\nDeparture Time: $hour:$minutes $ampm\n\nGoing to: $going\n\nFlight Number: $flightnumber\n\nPayment Method: $pay\n\nSong Requests: $song\n\nComments: $comments";

if(mail($to,"Slap it - message from Kabeoke.com!",$message,"From: $email\n")) {

}

else {

echo "There was a problem sending the mail. Please check that you filled in the form correctly.";

}

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/220013-php-form-back-and-bringing-the-ruckus/
Share on other sites

try

<?
$select=$_POST['select'];
$name=$_POST['name'];
$email=$_POST['email'];
$confirmail=$_POST['confirmail'];
$month=$_POST['month'];
$day=$_POST['day'];
$year=$_POST['year'];
$leaving=$_POST['leaving'];
$hour=$_POST['hour'];
$minutes=$_POST['minutes'];
$ampm=$_POST['ampm'];
$going=$_POST['going'];
$flightnumber=$_POST['flightnumber'];
$pay=$_POST['pay'];
$song=$_POST['song'];
$comments=$_POST['comments'];
$to="[email protected]";
$message="Message Type: $select\n\nName: $name\n\nEmail: $email\n\n$confirmail\n\nDate of Journey: $month, $day, $year\n\nLeaving From: $leaving\n\nDeparture Time: $hour:$minutes $ampm\n\nGoing to: $going\n\nFlight Number: $flightnumber\n\nPayment Method: $pay\n\nSong Requests: $song\n\nComments: $comments";

if(mail($to,"Slap it - message from Kabeoke.com!",$message,"From: $email\n")) {
header('Location:http://www.kabeoke.com');
} 
else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}


?>

 

Thanks Rifts

 

It seems to work the same even with header after the mail bit. I'm beginning to think that this has something to do with an email address verifier at the server - it works with established email addresses entered, but not with random stuff.

 

Anyways, thanks very much for your suggestion.

The From: header should contain an email address that is valid on the server, not the email address of the person submitting the form. That should go in a Reply-to: header if needed.

 

The header() redirect shouldn't be called before the mail() function has completed, and it should actually be conditional upon the mail() function's success, and be followed immediately by an exit();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.