daddyalfie Posted June 3, 2011 Report Share Posted June 3, 2011 The following short script is something I inherited from a website I am updating for my client. My client claims he receives the last "error message" in the script along with messages he even DOES receive! I am not expert enough with PHP to even start to analyze the problem! Can you help? Alfie <?php $to = "chmyrockin@blueridge.net" ; $from = $_REQUEST['email'] ; $name = $_REQUEST['name'] ; $headers = "From: $from"; $subject = "Information About Chimney Rock Inn"; $fields = array(); $fields{"name"} = "name"; $fields{"phone"} = "phone"; $fields{"email"} = "email"; $fields{"arrival"} = "arrival"; $fields{"DateLeaving"} = "DateLeaving"; $fields{"roomtype"} = "roomtype"; $fields{"adults"} = "adults"; $fields{"children"} = "children"; $fields{"homenumber"} = "homenumber"; $fields{"cottagetype"} = "cottagetype"; $fields{"comments"} = "comments"; $body = "We have received the following information:\n\n"; foreach($fields as $a => ${ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: chmyrockin@blueridge.net"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. You will be receiving more information shortly from us."; 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) {print "Thank You for Us! You will be contacted soon about your request" ;} else {print "We encountered an error sending your mail, please notify chmyrockin@blueridge.net"; } } } ?> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 8, 2011 Report Share Posted June 8, 2011 y client claims he receives the last "error message" in the script along with messages he even DOES receive! Can you rephrase this? Are you saying that users still receive error messages within the form, even when the form successfully submits and the client receives emails from the form? Quote Link to comment Share on other sites More sharing options...
jstern Posted June 9, 2011 Report Share Posted June 9, 2011 I dont think this will cause any errors, but the line $headers = "From: $from"; isnt printing whats in the variable, rather literally "From: $from" since the variable isnt escaped. Which might cause the line: $send = mail($to, $subject, $body, $headers); to fail (.?) I've never sent headers using mail() before, and would also explain why send2 works (uses a different header ($headers2)) My suggestion: change: $headers = "From: $from"; to: $headers = "From: " . $from; Quote Link to comment Share on other sites More sharing options...
BeeDev Posted June 10, 2011 Report Share Posted June 10, 2011 Change to: $headers = "From: " . $from; If you put variables in double quotes they usually get parsed instead of literal '$from' it will be replaced with the variable's value. So that doesn't make any difference. We encountered an error sending your mail, please notify chmyrockin@blueridge.net If your client is receiving this message then maybe something wrong with your server's PHP Mail() configuration? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.