Log in

View Full Version : Designing a PHP email form confirmation page



rharris07
10-25-2006, 01:10 AM
Hello everyone, I have a problem with a PHP email form and was wondering if I could get some help here.

I have a simple form on a contact page asking for email, subject title, and message. Once the user hits Send, it takes them to a confirmation page, and there is my problem.

This is what I have for that confirmation page -


<?php
$to = "email@address.com";

$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Return-Path: " . $from . "\r\n";
$from = $_POST['sender']; if ( ereg("\r",$from) || ereg("\n",$from) || ereg("%",$from) ) die("Why ?? ");

if ( mail($to,$subject,$message,$headers) ) {
echo
"The email has been sent.
<br><br>
<a href='index.html'>Click here to Return</a>";
}else{
echo "The email has failed.
<br><br>
<a href='index.html'>Click here to Return</a>";
}

?>


Here is my question - how do I make this page look like the rest of the site? I don't know PHP well enough to create a look for this page, instead of the plain white page with black lettering.

I appreciate any help I can get!!

Thanks so much,

Ryan

thetestingsite
10-25-2006, 01:14 AM
well you can use HTML in PHP, simply start out with the html page, then where-ever you want the confirmation to appear, stop the HTML, then start the PHP code. This may look like this:



<html>
<head>
<title>Untitled</title>
</head>
<body>

<!--Add whatever tables or whatnot you need-->

<?php

$to = "email@address.com";

$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Return-Path: " . $from . "\r\n";
$from = $_POST['sender']; if ( ereg("\r",$from) || ereg("\n",$from) || ereg("%",$from) ) die("Why ?? ");

if ( mail($to,$subject,$message,$headers) ) {
echo
"The email has been sent.
<br><br>
<a href='index.html'>Click here to Return</a>";
}else{
echo "The email has failed.
<br><br>
<a href='index.html'>Click here to Return</a>";
}

?>

</body>
</html>


That's it. Simple,yet effective.

rharris07
10-25-2006, 02:47 AM
Hey that worked! Thank you so much for your help!!!!


Thanks again,

Ryan