1

I have following PHP code to submit single input:

<?php

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$mailTo = '[email protected]';
$mailFrom = '[email protected]';
$subject = 'Call Back EN';

$body = ($_GET['number']) ? $_GET['number'] : $_POST['number'].'<br />';
$body .= 'Server IP:'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'<br />';
$body .= 'Czas:'.date('Y-m-d H:i:s').'<br />';

mail($mailTo, $subject, $number, "From: ".$mailFrom);


?>

But the only field I'm getting by email is number - what I'm doing wrong?

2
  • 3
    Well, you're sending only $number... Commented Aug 9, 2011 at 12:13
  • 1
    in the mail call, did you meant $body instead of $number? Commented Aug 9, 2011 at 12:14

3 Answers 3

4
mail($mailTo, $subject, $body, "From: ".$mailFrom);

the body is act like email contents,
but you supplied it using variable $number,
that is why you only getting number in your email

second problem, where is the $headers ?

http://php.net/manual/en/function.mail.php

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

this should give you clearer picture

$headers .= "From: [email protected]";
mail($mailTo, $subject, $body, $headers);
Sign up to request clarification or add additional context in comments.

Comments

2

You are getting only number because you are not sending the body. try this

 <?php

 $headers  = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 $mailTo = '[email protected]';
 $mailFrom = '[email protected]';
 $subject = 'Call Back EN';

 $body = ($_GET['number']) ? $_GET['number'] : $_POST['number'].'<br />';
  $body .= 'Server IP:'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'<br />';
 $body .= 'Czas:'.date('Y-m-d H:i:s').'<br />';

 mail($mailTo, $subject, $body, "From: ".$mailFrom);


?>

Comments

1

I think you should be inserting $body instead of $number

mail($mailTo, $subject, $body, "From: ".$mailFrom);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.