Jump to content

Spaces in text input areas - PHP forms


bigshwa05

Recommended Posts

After hours of endless searching of google for some help or information on this issue i thought i'd reach out to the community.

I am trying to use a very simple PHP script to process the contents of a standard html form.  The problem that's occurring is the FULL NAME field cuts off everything after the first word.

ie. if i enter Billy Ray Cyrus in the FULL NAME textbox when the form is processed and transmitted all that is included is Billy. ???

I am trying to use the FULLNAME textbox to populate the sender line of the email.

Here is the form and the code i am using to process it any help would be greatly appreciated.


//*****HTML FORM*****


<form method="post" action="sendmail.php"><table width="100%" border="0">
  <tr>
    <td width="21%">
      Full Name: </td>
    <td width="79%"><input name="fullname" type="text" /></td>
  </tr>
  <tr>
    <td>Email:</td>
    <td><input name="email" type="text" /></td>
  </tr>
  <tr>
    <td>City:</td>
    <td><input name="city" type="text" /></td>
  </tr>
  <tr>
    <td>Apply to: </td>
    <td>
      <select name="applyto">
        <option value="hr1@hrcompany.com">Mr. Bean</option>
        <option value="hr2@hrcompany.com">Mrs. Corn</option>
<option value="hr3@hrcompany.com">Ms. Carrot</option>
        </select>
    </td>
  </tr>
  <tr>
    <td>Position:</td>
    <td><select name="position">
        <option value="Promotional Rep">Promotional Rep</option>
        <option value="Demonstrator">Demonstrator</option>
<option value="Field Manager">Field Manager</option>
<option value="Cosmetic Demonstrator">Cosmetic Demonstrator</option>
<option value="Hair Stylist">Hair Stylist</option>
</select></td>
  </tr>
</table>

        <br>
        Please Copy and Paste Your Resume :<br>
<textarea name="resume" rows="15" cols="60"></textarea>
<br>
<input type="submit">
</form>


// **** PHP SCRIPT TO PROCESS FORM DATA ******


<body>
<?php
$to = $_REQUEST['applyto'] ;
$subject =  $_REQUEST['position'] . " + " . $_REQUEST['city'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['resume'] ;
$headers = "From:$fullname";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>
</body>
</html>
Link to comment
Share on other sites

[CODE]<?php
$to = $_REQUEST['applyto'] ;
$subject =  $_REQUEST['position'] . " + " . $_REQUEST['city'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['resume'] ;
$headers = "From:$_POST[fullname]";  #<-- line modified
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?> [/CODE]
Link to comment
Share on other sites

I'm pretty sure the full variable is getting passed to the processing page.  You can test by putting the following line at the top of the code and you will see all your $_POST variables.

[code]echo "POSTS: <pre>".print_r($_POST,TRUE)."</pre>";[/code]

I think your problem is that the "From:" header is looking for a little different format.  Try one of these:
[code]
$headers = "From: {$_POST['fullname']} <$email>";
//or
$headers = "From: $email";
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.