Data not getting to email

Hi. I have a html form, and one of the fields is

<input name="textfield" type="text" id="textfield" size="30" maxlength="35" class="txtField" />

For the php I do

$to = "data@mySite.com";
$subject = "Card Purchase";
$sender = $_SESSION['sender'];
$senEmail = $_POST['textfield'];
$body = "Senders name " . sender . "\
" . "Senders Email " . senEmail;
mail($to, $subject, $body);

I am not worried about the session variable as of yet, just the POST variable I am trying to send. When I get the email, this is displayed

Senders name sender
Senders Email senEmail

I have entered a email address into the field which is what should be getting sent to my email. Am I doing something wrong here?

thanks

Not unless you’ve omitted the method=“post” attribute on your form or specified it as ‘get’.

You have 2 inputs identically named.

Did you actually put something in $sender and $senEmail?

rephrase Did you try echo $senEmail; to make sure your post variables are being filled correctly?

Any adivse?

cheers

Nothing even goes through with an echo. Is it something I am doing wrong with the html line?

My form is looking like

<form method="POST" onsubmit="return validateFormOnSubmit1(this)" action="sendEmail.php">
      <p class="pos">E-mail Address <input type="text" name="textfield" size="30" maxlength="35" class="txtField" />
      <input name="Submit" type="submit" value="Submit" /></p>
      <p ><textarea class="field" name="textarea" id="textarea" cols="60" rows="5"></textarea></p>
      <p ><input name="textfield" type="text" id="textfield" size="60" maxlength="35" class="field" /></p>
    </form>

And my php is like

<?php
session_start();
if(isset($_POST['Submit'])) {

$to = "data@mySite.com";
$subject = "Card Purchase";
$sender = $_SESSION['sender'];
$senEmail = $_POST['textfield'];
$body = "Senders name " . $sender . "\
" . "Senders Email " . $senEmail;
mail($to, $subject, $body);
echo $senEmail;
} else {

echo "ERROR!";

}
?>

The form is in a html page, which I dont think should make a difference. I really cant see what i am doing wrong?

Kool. With that, I get in my email just
Senders name
Senders Email

Is there any reason according to the code I have shown as to why my email address doesnt get through?

You didn’t put dollar signs before the variables you use:


$body = "Senders name " . [COLOR="Red"]$[/COLOR]sender . "\
" . "Senders Email " . [COLOR="Red"]$[/COLOR]senEmail;

:slight_smile: