Log in

View Full Version : php help please



stebbi
03-04-2009, 01:04 AM
Hi this is probebly simple but I cant seem to get it right.

php code for mail form


if($send)
{header( "Location:http://www.example.com/thankyou.html");}
else
{print "We encountered an error sending your mail,


This all seems to work fine however once its directed to thankyou.html I
would like it to print a thank you message I have tried several attempts but all failed...Many thanks for your help with this.

Nile
03-04-2009, 01:09 AM
1. Make your code neat:


if($send) {
header("Location:http://www.example.com/thankyou.html");
} else {
print "We encountered an error sending your mail,


2. What do you mean print a thank you message? Do you want to print it from the mail page? Or do you want to edit thankyou.html and on that page say: "Thanks for your spam!(haha)" or something like that?

stebbi
03-04-2009, 01:17 AM
Yes on the thankyou.html there a centered box that will display any errors or in this case a message thank you for contacting us! funny i tried to fix this );} when I do the script dont work

stebbi
03-04-2009, 01:22 AM
Heres the code incase u need



<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Message"} = "Message";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: example.net";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.pokersaint.net";

if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.example.com/thankyou.html");}
else
{print "We encountered an error sending your mail, please notify webmaster@example.net"; }
}
}
?>

Nile
03-04-2009, 01:28 AM
Hmm... Why not put the centered box on the page above, and on thankyou.html is only when everything is good...

stebbi
03-04-2009, 01:35 AM
you can see it here if you like ...tell me what you think is best http://cardiffroyalcabs.com/4x4/index.html

the mail form is at the bottom of the page

Nile
03-04-2009, 01:36 AM
What page is the code you listed above from? contact.php?

stebbi
03-04-2009, 01:39 AM
yes ........

Nile
03-04-2009, 01:39 AM
Ok, then I think my idea is fine.

stebbi
03-04-2009, 01:42 AM
can you show me how to do this.

Nile
03-05-2009, 01:09 PM
Well, it seems that it's printing all the errors out, so just but a big div in the beginning:


<div id="errors">
/*PHP CODE HERE*/
</div>