Forum Moderators: coopster

Message Too Old, No Replies

PHP email form does not deliver checkboxes

E-mail delivers text inputs only

         

ed_edin

12:16 pm on Sep 25, 2004 (gmt 0)

10+ Year Member



Hi

I have an e-mail form which collects name, e-mail address and then a checkbox <input type="checkbox" name="checkbox" value="YES">. My PHP script e-mails me the name and e-mail fine, but not the checkbox. Any ideas what I'm doing wrong?

<?php
//create short variable names
$name=$HTTP_POST_VARS['name'];
$email=$HTTP_POST_VARS['email'];
$checkbox=$HTTP_POST_VARS['checkbox'];
$toaddress = 'myemail@example.com';
$subject = 'RESULTS';
$mailcontent = 'Name: '.$name."\n"
.'Email: '.$email."\n"
.'Checkbox: '.$checkbox."\n";
$fromaddress = 'From: myemail@example.com';

mail($toaddress, $subject, $mailcontent);
?>

It arrives blank:

Name: Their Name
Email: theiremail@example.com
Checkbox:

mincklerstraat

1:05 pm on Sep 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This one stumps me at first.
I'd suggest debugging by putting the following at the top of the php part:
echo '<pre>';
print_r($HTTP_POST_VARS);
echo '</pre>';
die();
and seeing what's happening to the checkbox part - then modifying your HTML to see if this gives you any positive return.

nb in the future try using $_POST('whatever') instead of $HTTP_POST_VARS['whatever'] if using a PHP manufactured after the industrial revolution, it'll be more future-friendly.