Jump to content

Sendmail not returning all strings


the_real_JLM

Recommended Posts

I garantee I'm doing something wrong here, but I cant seem to figure it out... It is returning everything but the Drivers License value. sorry to keep pestering you guys :o

 

HTML form code:

<form method="post" action="sendmail.php">
  
  <input name="email" type="text" value="Email Address" />
  <input name="firstname" type="text" value="First Name" />
  <input name="lastname" type="text" value="Last Name" />
  <br />
  <input name="telephone" type="text" value="Telephone" />
  <input name="drivers" type="text" value="Drivers License? (Y/N)" />
  <input name="position" type="text" value="Position" />
  <br />
  <input name="address" type="text" value="Address" size="73" />
  <br />
  <textarea name="message" rows="15" cols="70">Employment History:

References:

Availability:

Comments:</textarea>
  <br />
  <input type="submit" />
  </form>

 

sendmail code:

<?php
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;
  $firstname = $_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $telephone = $_REQUEST['telephone'] ;
  $drivers = $_REQUEST['drivers'] ;
  $position = $_REQUEST['position'] ;
  $address = $_REQUEST['address'] ;

  mail( "[email protected]", "Job Application",
    $firstname . ' ' . $lastname . "\n" . $telephone . "\n" . 'Drivers License: ' . $drivers . "\n" . 'Position Applying For: ' . $position . "\n" . 'Address: ' . $address . "\n" . $message , "From: $email" );
  header( "Location: index.php" );
?>

 

Email body Recieved:

Jody McIvor

0000000000

Drivers License:  <---should be a "Y" here, as entered on the php form, but returns nothing

Position Applying For: Office Monkey

Address: HereThere Street

Employment History:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

 

References:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

 

Availability:blah blah blah blah blah

 

Comments:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

Link to comment
https://forums.phpfreaks.com/topic/98007-sendmail-not-returning-all-strings/
Share on other sites

I took your original code, modified it somewhat and tested the modified code. It worked fine. Here's the modified code:

<?php
$post_array = array('name' => '', 'drivers' => 'Drivers License: ',
                    'position' => 'Position Applying For: ', 'address' => 'Address: ', 'message' => '');
if (isset($_POST['submit'])) {
  $email = $_POST['email'] ;
  $tmp = array();
  $tmp['name'] = '';
  foreach ($_POST as $key => $val)
     switch($key) {
        case 'firstname':
        case 'lastname':
            $tmp['name'] .= $val . ' ';
            break;
        case 'email':
            $email = stripslashes($val);
            break;
        case 'submit':
            break;
        default:
            $tmp[$key] = trim(stripslashes($val));
     }
  $tmp2 = array();
  foreach ($post_array as $key => $lbl)
        $tmp2[] = ($lbl != '')?$lbl . stripslashes($tmp[$key]):$tmp[$key];

  mail( "[email protected]", "Job Application",implode("\n",$tmp2)."\n" , "From: $email" );
}
?>
<html>
<head>
<title>Job Application</title>
</head>
<body>
<form method="post" action="">

  <input name="email" type="text" value="Email Address" />
  <input name="firstname" type="text" value="First Name" />
  <input name="lastname" type="text" value="Last Name" />
  <br />
  <input name="telephone" type="text" value="Telephone" />
  <input name="drivers" type="text" value="Drivers License? (Y/N)" />
  <input name="position" type="text" value="Position" />
  <br />
  <input name="address" type="text" value="Address" size="73" />
  <br />
  <textarea name="message" rows="15" cols="70">Employment History:

References:

Availability:

Comments:</textarea>
  <br />
  <input type="submit" name="submit" value="Send Info" />
  </form>
</body>
</html>

 

Ken

I took your original code, modified it somewhat and tested the modified code. It worked fine. Here's the modified code:

<?php
$post_array = array('name' => '', 'drivers' => 'Drivers License: ',
                    'position' => 'Position Applying For: ', 'address' => 'Address: ', 'message' => '');
if (isset($_POST['submit'])) {
  $email = $_POST['email'] ;
  $tmp = array();
  $tmp['name'] = '';
  foreach ($_POST as $key => $val)
     switch($key) {
        case 'firstname':
        case 'lastname':
            $tmp['name'] .= $val . ' ';
            break;
        case 'email':
            $email = stripslashes($val);
            break;
        case 'submit':
            break;
        default:
            $tmp[$key] = trim(stripslashes($val));
     }
  $tmp2 = array();
  foreach ($post_array as $key => $lbl)
        $tmp2[] = ($lbl != '')?$lbl . stripslashes($tmp[$key]):$tmp[$key];

  mail( "[email protected]", "Job Application",implode("\n",$tmp2)."\n" , "From: $email" );
}
?>
<html>
<head>
<title>Job Application</title>
</head>
<body>
<form method="post" action="">

  <input name="email" type="text" value="Email Address" />
  <input name="firstname" type="text" value="First Name" />
  <input name="lastname" type="text" value="Last Name" />
  <br />
  <input name="telephone" type="text" value="Telephone" />
  <input name="drivers" type="text" value="Drivers License? (Y/N)" />
  <input name="position" type="text" value="Position" />
  <br />
  <input name="address" type="text" value="Address" size="73" />
  <br />
  <textarea name="message" rows="15" cols="70">Employment History:

References:

Availability:

Comments:</textarea>
  <br />
  <input type="submit" name="submit" value="Send Info" />
  </form>
</body>
</html>

 

Ken

works nicely, and fixed the issue, thanks ken :)

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.