PDA

View Full Version : contact form php help


JJtheJoker
05-19-2011, 05:45 AM
Hey again, I've been coding a contact page for my website using php and I've got everything working, like it sends to my email ect, but I'm trying to add a confirmation page, that says for example: Thank You For Contacting Us!, and I basically followed this tutorial that said you can use this bit of code, and it does bring you to a new page but none of my styling works on it

$TheResults = <<<EOD
I copied the code from my contact page and replaced the contents of the maintext div with what I wanted it to say
EOD;

echo "$TheResults"

www.brave-design.ca/contact.html (http://www.brave-design.ca/contact.html)

I'm not sure if this is even possible or if there's a better way you guys know of,

thanks again, Josh:)

JJtheJoker
05-19-2011, 05:47 AM
<?php

/**/

/*Subject and Email Variables*/

$emailSubject = 'Brave-Design Contact Form!';
$webMaster = 'joshjames@love.com';

/*Gathering Data Variables*/

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$messageField = $_POST['message'];
$subscribeField = $_POST['subscribe'];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Message: $message <br>
Subscribe: $subscribe <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-Type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);


/*Results Rendered in HTML*/

$TheResults = <<<EOD
/*Entire HTML code from my contact page*/
EOD;

echo "$TheResults"

?>

Corrosive
05-19-2011, 06:03 AM
Hiya, moved to PHP board.

You need to redirect after send so try something like;

header("Location:http://www.xxxxxxx.com/thankyou.php");
exit;

at the end of your code (before the closing curly brace).