PDA

View Full Version : php newbie! help!



suz
March 29th, 2007, 09:29 AM
hi,

I have used the PHP contact form and have it working perfectly - only thing is i dont like the screen that is displayed after you have sent the mail.

How can I change this to my own email confirmation page? im a complete newbie to php so have no idea!

Any help would be much appreciated!

bwh2
March 29th, 2007, 09:34 AM
post your code and tell us what you want it to output.

suz
March 29th, 2007, 09:45 AM
This is the contact form working, currently i have it set to email me so if you want to try it out its fine...
this is the web address http://www.suz-j.com/donnie/contact.html

and i want it to display this page when the email has been submitted
http://www.suz-j.com/donnie/confirm.html

any ideas?

bwh2
March 29th, 2007, 10:02 AM
you need to post the php code you're using to send the mail.

suz
March 29th, 2007, 01:04 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<?php
if(isset($_POST['submit'])) {

$to = "suzyicz@btinternet.com";
$subject = "Website mail";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

foreach($_POST['check'] as $value) {

$check_msg .= "Checked: $value\n";

}

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message\n $check_msg";

header( 'Location: http://www.suz-j.com/donnie/confirm.html' );
mail($to, $subject, $body);

} else {

echo "blarg!";

}
?>

</body>
</html>

danulf
March 29th, 2007, 03:05 PM
I get an error message when I try to mail you... You could try to put the php code on top, then do a meta redirect instead... I did a similar thing recently and that worked fine for me

suz
March 29th, 2007, 03:44 PM
it does say there has been an error but i still seem to get the email??

DangerousDan
March 29th, 2007, 04:26 PM
Not sure about this, but wouldn't you want the header to be after the mail statement?


mail($to, $subject, $body);
header( 'Location: http://www.suz-j.com/donnie/confirm.html' );

bwh2
March 29th, 2007, 04:49 PM
dangerous dan is right. but you also want to check that the mail did in fact send.


/* try to mail */
if( mail( $to, $subject, $body ) ) {
header( 'Location: http://www.suz-j.com/donnie/confirm.html' );
}
else {
echo 'error sending';
}

suz
March 30th, 2007, 09:39 AM
dangerous dan is right. but you also want to check that the mail did in fact send.


/* try to mail */
if( mail( $to, $subject, $body ) ) {
header( 'Location: http://www.suz-j.com/donnie/confirm.html' );
}
else {
echo 'error sending';
}


i tried this but with no luck, again it said error on line 40 - but there is no line 40!