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="beepbeepyeah@kabeoke.com";

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
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="beepbeepyeah@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")) {
header('Location:http://www.kabeoke.com');
} 
else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}


?>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.