Jump to content

php mail program sends email but doesn't pick up form data?


mikeconley48

Recommended Posts

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");

 

 

?>

  $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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.