Jump to content

PHP Mailer Form


Recommended Posts

My website has an simple form that I use for customer interactions.  I have just included a checkbox but cannot figure out how to set a variable to show that the checbox is checked or not when the form is automatically mailed to us. My code is below:

 

<?php

$m1 = $_POST['m1'];
$m2 = $_POST['m2'];
$e1 = $_POST['e1'];
$e2 = $_POST['e2'];
$pc = $_POST['pc'];
$br = $_POST['br'];
$cn = $_POST['cn'];
$fn = $_POST['fn'];
$bld = $_POST['bld'];
$eld = $_POST['eld'];
$cb = $_POST['cb'];

if (eregi('http:', $bld)) {
die ("Naughty Naughty! ");
}
if(!$e1 == "" && (!strstr($e1,"@") || !strstr($e1,".")))
{
echo "<h2>Error - Enter valid e-mail</h2>\n";
$badinput = "<h2>Form Not Sent</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($m1) || empty($e1) || empty($bld )) {
echo "<h2>Error - fill in all fields</h2>\n";
die ("Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$m1 = $m1;
$subject = $m1;

$cn = stripcslashes($cn);

$message = " $todayis [EST] \n
Main Tenanat Name : $m1 \n
Secondary Tenant Name: $m2 \n
Primary Tenant Email: $m1 ($e1)\n
Secondary Tenant Email: $e2 \n
Property Code: $pc
Bedrooms: $br
Coordinator Name: $cn \n
Firm Name: $fn \n 
Begin Lease Date: $bld \n
End Lease Date: $eld \n
Agree to Terms: $cb \n
";

$from = "From: $e1\r\n";


mail("[email protected]", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $m1 ?> ( <?php echo $e1 ?> )
<hr />
</p>

 

The checkbox is labeled "Agree to Terms" on this page. Thanks in advance for your help

 

Matthew

Link to comment
https://forums.phpfreaks.com/topic/193907-php-mailer-form/
Share on other sites

Anytime you use an input it should return the name/value pair of that input. If a checkbox is checked then checking against that variable will return the value of the checkbox.

For instance if this checkbox is checked:

<input type="checkbox" name="Check" value="1" />

 

Then this will be true:

$_POST['Check'] == 1;

Link to comment
https://forums.phpfreaks.com/topic/193907-php-mailer-form/#findComment-1020460
Share on other sites

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.