Jump to content

Form Mail - Not all contents are going into my email.


nyjet88

Recommended Posts

Here is the form code:

 

<form name="formcheck" method="post" action="sendmail.php" onsubmit="return formCheck(this);">

 

 

 

 

  <table width="414" height="289" border="0">

    <tr>

      <td width="164" height="31"><div align="right" class="style5">Name:</div></td>

      <td width="10"> </td>

      <td width="228"><label>

        <input name="name" type="text" id="name" size="30">

      </label></td>

    </tr>

    <tr>

      <td height="31"><div align="right" class="style5">Company:</div></td>

      <td> </td>

      <td><label>

        <input name="company" type="text" id="company" size="30">

      </label></td>

    </tr>

    <tr>

      <td height="35"><div align="right" class="style5">E-Mail Address:</div></td>

      <td> </td>

      <td><label>

        <input name="email" type="text" id="email" size="30">

      </label></td>

    </tr>

    <tr>

      <td valign="top"><div align="right" class="style5">Question/Comments:<br>

        <span class="style8">(Limit 300 Characters)        </span></div></td>

      <td valign="top"> </td>

      <td><label>

        <textarea name="comments" cols="30" rows="10" wrap="physical" id="comments"></textarea>

      </label></td>

    </tr>

    <tr>

      <td valign="top"><label></label></td>

      <td valign="top"> </td>

      <td><label></label>

        <input type="submit" name="submit" id="submit" value="Submit"></td>

    </tr>

  </table>

</form>

 

Here is the PHP code:

 

<?php

  $name = $_REQUEST['name'] ;

  $company = $_REQUEST['company'] ;

  $email = $_REQUEST['email'] ;

  $comments = $_REQUEST['comments'] ;

 

  mail( "[email protected]", "Info Request from www.systek.com",

  $comments, "From: $email" );

  header( "Location: http://www.systek.com/NEW/thankyou.html" );

?>

 

How can I get the php file to display the $name, $company, $email, $comments in the email?

 

I thought maybe I needed to do $name, $company, $email, $comments, "From: $email" ); but that did not work...it actually didn't even process at that point.

 

Any help is GREATLY appreciated.

 

Thanks in advance,

 

John

A couple things to note before we get to the initial issue. Your code is open to injection attacks, and I'd suggest fixing this before worrying about functionality.

 

1. Header injection. You should sanitize all input... at the very least remove any line breaks from the user input.

Read more: http://www.securephpwiki.com/index.php/Email_Injection

 

2. Content injection. You should sanitize the body of the email with htmlentities()

Well, start walking before you start to run. Last thing you want is a bot abusing your script to send Nigerian spam ;)

 

I'd suggest using a known mailer class if all of this is still over your head. Swiftmailer is a good one, and can be found here:

http://www.swiftmailer.org/

 

No sense in reinventing the wheel

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.