www.webdeveloper.com
Results 1 to 9 of 9

Thread: [RESOLVED] PHP Form submitted empty

  1. #1
    Join Date
    Dec 2008
    Posts
    19

    resolved [RESOLVED] PHP Form submitted empty

    When the form is submitted, I get the email but the information filled in are not appearing in the email. I receive an empty form. Also, the "from" is not displaying in the email rather it displays "Apache". Any help
    ----------------------
    Here is my .php file:

    <?php

    $sendTo = "nobody@somebody.net";
    $subject = "Inquiry";

    $headers = "From: " . $_POST['email'] . "\r\n";

    $name=$_POST['name'];
    $company=$_POST['company'];
    $email=$_POST['email'];
    $telephone=$_POST['telephone'];
    $message=$_POST['message'];


    $mime_boundary = "----Some Inquiry----".md5(time());

    $headers .= "Reply-To: SIWWM <somebody@nobody.net> \r\n";
    $headers .= "Return-path: " . $_POST['email'] . "\r\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

    $message .= "--$mime_boundary\n";
    $message .= "Content-Type: text/html; charset=iso-8859-1";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";

    $message .= "<html>\n";
    $message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";

    $message .= "<table width=\"800\" height=\"159\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >";
    $message .="<tr>";
    $message .="<td height=\"66\" colspan=\"4\" bgcolor=\"#CCCCCC\"></td>";
    $message .="</tr>";
    $message .="<tr>";
    $message .="<td width=\"1%\"></td>";
    $message .="<td colspan=\"3\">&nbsp;</td>";
    $message .="</tr>";
    $message .="<tr>";
    $message .="<td>&nbsp;</td>";
    $message .="<td width=\"100\"><b>Name</b></td>";
    $message .="<td align=\"left\" >:</td>";
    $message .="<td>$name</td>";
    $message .="<tr>";
    $message .="<td>&nbsp;</td>";
    $message .="<td><b>Company</b></td>";
    $message .="<td>:</td>";
    $message .="<td>$company</td>";
    $message .="</tr>";
    $message .="</tr>";
    $message .="<tr>";
    $message .="<td>&nbsp;</td>";
    $message .="<td><b>Email</b></td>";
    $message .="<td>:</td>";
    $message .="<td>$email</td>";
    $message .="</tr>";
    $message .="<tr>";
    $message .="<td>&nbsp;</td>";
    $message .="<td><b>Telephone</b></td>";
    $message .="<td>:</td>";
    $message .="<td>$telephone</td>";
    $message .="</tr>";
    $message .="<tr>";
    $message .="<td>&nbsp;</td>";
    $message .="<tr>";
    $message .="<td height=\"21\" colspan=\"4\" bgcolor=\"#CCCCCC\"></td>";
    $message .="</tr>";
    $message .="<td><b>Message</b></td>";
    $message .="<td>:</td>";
    $message .="<td>$message</td>";
    $message .="</tr>";
    $message .="<tr>";
    $message .="</table>";
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--$mime_boundary--\n\n";

    mail($sendTo, $subject, $message, $headers);

    if($mail)
    {
    header('Location:index.html?msg=yes');
    }
    else
    {
    header("Location:http://www.blahblah.com?msg=no");
    }

    ?>

    ----------------------
    Here is my .html form:

    <form action="contactus.php" method="post" onSubmit="return submitForms()" enctype="multipart/form-data" id="form">

    <table cellspacing="0" cellpadding="0" class="form">
    <tr> <td style="width:198px; height:128px"><table cellspacing="0" cellpadding="0">
    <tr>
    <td style="width:3px; height:27px" align="right">Name:</td>
    <td style="width:5px; height:27px"><input name=" Name" type="text"></td>
    </tr>

    <tr>
    <td style="width:3px; height:27px" align="right">Company:</td>
    <td style="width:5px; height:27px"><input name="Company" type="text" value=""></td>
    </tr>
    <tr>
    <td style="width:3px; height:27px" align="right">Telephone:</td>
    <td style="width:5px; height:27px"><input name="Input" type="text" value=""></td>
    </tr>
    <tr>
    <td style="width:3px; height:27px"align="right">Email:</td>
    <td style="width:5px; height:27px"><input name="Input" type="text" value=""></td></tr>
    <td>
    <tr>
    <td style="width:202px; height:109px" align="right">Message:</td> </td>
    <td style="width:202px; height:109px" align="right"><textarea name="textarea" cols="0" rows="0"></textarea></td>
    </tr>
    <tr>
    <td <br style="line-height:1px">
    <img src="images/spacer.gif" alt="" width="116" height="1"><strong><a href="#" onClick="document.getElementById('form').reset()">reset</a></strong><img src="images/spacer.gif" alt="" width="15" height="1"><strong><a href="#" onClick="document.getElementById('form').submit()">send</a></strong> </td>
    </tr>
    </table></td>

    </tr>
    </table>
    </form>

  2. #2
    Join Date
    Jan 2009
    Posts
    35
    You might want to approach this differently. You should maybe start by making one line of input to test. And then work from there.

    For example, start over, simple. And try something like this:

    <?php

    $ip= $_SERVER['REMOTE_ADDR'];
    $httpref = $_SERVER['HTTP_REFERER'];
    $httpagent = $_SERVER['HTTP_USER_AGENT'];
    $name = $_POST['name'];
    $compname = $_POST['compname'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $todayis = date("l, F j, Y, g:i a") ;
    $space = ", ";
    $to = "email@email.com";
    $subject = "Subject";
    $selected_radio = $_POST['radiobutton'];

    $body = "$todayis \n \n $name \n $phone \n $email \n $selected_radio";



    if (mail($to, $subject, $body))
    {
    echo("<p>Your form has been submitted. We will contact you shortly.</p>");
    }

    else {
    echo("<p>Message delivery failed. Please try again or contact us directly.</p>");
    }

    ?>

    Hope this helps

  3. #3
    Join Date
    Dec 2008
    Posts
    19
    Peteincali, thanks.
    I tried your suggestion and got the same error????

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    $company=$_POST['company'];
    <input name="Company" type="text" value="">
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Dec 2008
    Posts
    19
    Fang, "company" was changed and still the same error. Thanks...any other help is appreciated.

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    All of the names! Also check the names, they do not correspond with the post values.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    Dec 2008
    Posts
    19
    Thanks Fang.
    Yes, that was the problem, unmatched names. I can now see the data for "name", "company", "email", & "telephone". However, the data "message" in the text area box on the form is not showing in the email.

    The php code:

    $message=$_POST['message'];

    $message .="<td><b>Message</b></td>";
    $message .="<td>:</td>";
    $message .="<td>$message</td>";


    The form code:

    <td style="width:202px; height:109px" align="right">Message:</td> </td>
    <td style="width:202px; height:109px" align="right"><textarea name="message" cols="0" rows="0"></textarea></td>
    </tr>


  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    You are using $message as a string, for mail, and as the return value from the textarea.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  9. #9
    Join Date
    Dec 2008
    Posts
    19

    resolved



    Problem solved...Thanks to FANG. Peteincali, your input was appreciated, simple is always better...Thanks.

    PHP code:
    $info=$_POST['info'];

    HTML form code:
    $message .="<td><b>Message</b></td>";
    $message .="<td>:</td>";
    $message .="<td>$info</td>";
    $message .="</tr>";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles