Not Displaying Email in mail() Message

He has: 578 posts

Joined: Jun 2004

<?php
    $header
=\"From: $email\";
   
$subject=\"Quote Request\";
   
$message=\"From: $first $last \n E-Mail: $email \n Business: $biz \n Site Description: \n $desc\";
   
$first=$_GET['first'];
   
$last=$_GET['last'];
   
$email=$_GET['from'];
   
$biz=$_GET['biz'];
   
$desc=$_GET['desc'];



<!-- Begin Page -->
<div class=\"page\">



include 'http://madclassifieds.000k.net/html/header.html'



<!-- Begin Content -->
    <div class=\"content\">

        <div class=\"left\">
           
            if(mail(\"davidbacsik@gmail\",
$subject,$message,$header)) {
            echo \"<p>Quote Received!</p>\";
            }else{
            echo \"<p>Oh, Smudge!!</p><p>It seems there's been a problem recieving your request for a quote.  If you'd like to try it again, feel free to do so.\"; }
           
?>

and on the referrer page:

<?php
<input type=\"hidden\" value=\" echo\"$first\"\" name=\"first\">
            <input type=\"hidden\" value=\" echo\"
$last\"\" name=\"last\">
            <input type=\"hidden\" value=\" echo\"
$email\"\" name=\"from\">
            <input type=\"hidden\" value=\" echo\"
$biz\"\" name=\"biz\">
            <input type=\"hidden\" value=\" echo\"
$desc\"\" name=\"desc\">
?>

Thing is, this is the email I get:

From: Blah Blah
E-Mail:
Business: Di Boots
Site Description: blah

b

notice that the email isn't displayed. What's up?

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

You're using the values of $first, $last, etc before you define them. Use this:

<?php
   
/* grab and store the submitted data first! */
   
$first=$_GET['first'];
   
$last=$_GET['last'];
   
$email=$_GET['from'];
   
$biz=$_GET['biz'];
   
$desc=$_GET['desc'];

   
/* now use the values... */
   
$header=\"From: $email\";
   
$subject=\"Quote Request\";
   
$message=\"From: $first $last \n E-Mail: $email \n Business: $biz \n Site Description: \n $desc\";
?>

Btw, why not set method="post" ($_POST) for the form, so you don't dump all the form data into the URL?

He has: 578 posts

Joined: Jun 2004

Uhhh... Doi!!!

How could I have been so stupid!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.