Hi. For some reason, my mail script works, but it won't send any of the variables from the form. In other words, I get the email, but it is empty. Here is my code. Thanks in advance!

I have a form that is as follows:

<form name="ProcessScript" action="ProcessScript.php" method="post">
<input type="text" name="Name">
<input type="text" name="Email">
</form>

Then I have an email script that is the following:

<?php
@$Body = "This person wants to join your newsletter list\n\n"
"Name: $Name\n"
"E-mail: $Email\n";
mail("subscribe@mysite.com", "Subscription Request", $Body);
?>

    Are you getting any info in the email @ all? i.e.

    is the @body variable you set up working? does it come through in the email.... the way I normally do it is...

    File: ProcessScript.php

    <? php
    $msg .= "This person wants to join your newsletter list\n\n"
    $msg .= "Name:\t$name\n";
    $msg .= "E-mail:\t$email\n";

    $recipient = "subscribe@mysite.com";
    $subject = "Subscription Request";
    $mailheaders = "From: \t $name<> \n";
    $mailheaders .= "Reply-To: $email\n\n";

    mail($recipient, $subject, $msg, $mailheaders);

    ?>

    You may also want to do a test of Echo'ing the variables $email & $name to the browser to ensure they are getting passed through. Sometimes the Global_variables command w/ PHP can cause some problems with this as well..

      Yes, the email does come through, just none of the form variables are with it. How would I set up the @$Body variable? Even if I change the variable names to $ContactName and$EmailAddress, it still doesn't come through. Is there any other advice you can give me?

        Well let's see....

        Is the form passed directly to your PHP file? Nothing happens in between like a verfication file or something that echo's the data back to the user?

        If this is the case it's possible you may have to declare the variables agin using

        <input type="hidded" name="variable_name" value="$variable_name">

        where variable_name is what ever variable your dealing with i.e. $email.

        Pending everything is right in your php.ini file (mainly global variables is on) then there is no reason for a form not to pass the variables directly to the ProcessScript.php.

        I would try doing it this way....
        File below is your form.html

        <form name="ProcessScript" action="ProcessScript.php" method="post"> 
        <input type="text" name="Name"> 
        <input type="text" name="Email"> 
        </form> 
        

        Below is your ProcessScript.php file
        <? php
        $msg .= "This person wants to join your newsletter list\n\n"
        $msg .= "Name:\t$name\n";
        $msg .= "E-mail:\t$email\n";

        $recipient = "subscribe@mysite.com";
        $subject = "Subscription Request";
        $mailheaders = "From: \t $name<> \n";
        $mailheaders .= "Reply-To: $email\n\n";

        mail($recipient, $subject, $msg, $mailheaders);

        ?>

        try putting these two formats together and see if you get your variables through in your email.

          8 days later

          Try this for your form:
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

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

          <body>

          <form action="ProcessScript.php" method="post">
          <input type="text" name="Name">NAME
          <input type="text" name="Email" >EMAIL
          <input type="submit" name="Submit" value="Submit User Request">
          <input type="reset" value="Clear all form fields">

          </form>

          And this for your PHP:

          <?
          $message = <<<EOD
          This person wants to join your newsletter list.
          Name: $HTTP_POST_VARS[Name]
          E-mail: $HTTP_POST_VARS[Email]
          EOD;
          $ToAddress = ('someone@something.com');
          $FromAddress = $HTTP_POST_VARS[Email];
          $Subject = "User Wants to Join Newsletter ";

          $headers = "From: $FromAddress\r\n";
          mail($ToAddress,$Subject,$message,$headers);

          Good luck

            Write a Reply...