mikeconley48 Posted August 10, 2009 Share Posted August 10, 2009 My form mails but with no data. Can anybody spot what I am doing wrong? My html coding (separate program) uses POST as the form action. Here is the php program code: <?php $SendFrom = "Form Submission <[email protected]>"; $SendTo = "[email protected]"; $SubjectLine = "Get Involved Form Submission"; $ThanksURL = "thankyou.htm"; //confirmation page $msg="Values submitted by the user:\n"; foreach($_POST as $key => $val){ if (is_array($val)){ $msg.="Item: $key\n"; foreach($val as $v){ $v = stripslashes($v); $msg.=" $v\n"; } } else { $val = stripslashes($val); $msg.="$key: $val\n"; } } $Msg.= "\n" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\n" . $_SERVER["HTTP_USER_AGENT"]; $MsgBody = htmlspecialchars($Msg, ENT_NOQUOTES); //make safe // Send E-Mail and Direct Browser to Confirmation Page mail($SendTo, $SubjectLine, $Msg, "From: $SendFrom"); header("Location: $ThanksURL"); ?> Link to comment https://forums.phpfreaks.com/topic/169541-php-mail-program-sends-email-but-doesnt-pick-up-form-data/ Share on other sites More sharing options...
perrij3 Posted August 10, 2009 Share Posted August 10, 2009 I had a simpler problem before. I fixed it like this: $message = "Name:" . $_POST['name'] . "\n\n"; $message .= "Email:" . $_POST['email'] ."\n\n"; Link to comment https://forums.phpfreaks.com/topic/169541-php-mail-program-sends-email-but-doesnt-pick-up-form-data/#findComment-894529 Share on other sites More sharing options...
PFMaBiSmAd Posted August 10, 2009 Share Posted August 10, 2009 $msg, $Msg, and $MsgBody are three different variables. You need proof read your code to make sure it is logically doing what you expect (you switched from $msg to $Msg which lost most of the data from the form which was in $msg.) Link to comment https://forums.phpfreaks.com/topic/169541-php-mail-program-sends-email-but-doesnt-pick-up-form-data/#findComment-894532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.