Also, as far as the form is concerned, I actually did have the form in a separate .htm file, I just put the two together, separating them with the those tags to make them easier to read in the email.

On 10/31/2010 10:36, wrote:
I tested your code and besides adding a form to the beginning it works.

If you want to see the results of the posted for try.


you can see every position of the array passed and validate they are passing as 

Try this.

//if reallife is not set (Checked it will not pass)
// I am pretty sure I read where someone had responded with the isset




Richard L. Buskirk

-----Original Message-----
From: Ben Brentlinger []
Sent: Sunday, October 31, 2010 8:26 AM
Subject: Re: [PHP] questions about if statements regarding a checkbox

Here's the code I'm using with the exception of the php tags and the
redirect script that redirects to another page once the form is
submitted.  This is just a test script I'm working on in order to teach
myself php.  The php portion will be posted first, than the html form
related to the php.  I've got the code inside tags similar to the "code"
tag which only serves to serarate the php code from the html form.

$name = $_POST['firstname'] . ' ' . $_POST['lastname'];
$email = $_POST['email'];

if($_POST['reallife'] == "on")
$to = '';
$subject ='test email one';
$msg = "$name has filled out the test form. \n" .
"this is just a test message";
mail ($to, $subject, $msg, 'From:' . $email);

} else {

$to = '';
$subject ='test email two';
$msg = "$name has filled out the test form." ;
mail ($to, $subject, $msg, 'From:' . $email);

if($_POST['reallife'] == "on") {

$to = '$email';
$subject = "Thank you email number one";
$msg = "hello $name, \n" .
"thank you for filling out the form. \n" .
"This is the first of two test emails \n" .
"The second would have been sent \n" .
"if you had left the checkbox unchecked \n";
mail ($to, $subject, $msg, 'From:' . $;

header ("location:thankyoupage")

<div align="center">
<table border="0"
    cellpadding="3" cellspacing="0" width="59%">
<td colspan="2">
<h2 align="center">&nbsp;</h2>
<h2 align="center"><font color="blue" face="Arial">Contact Form</font></h2>
<p align="center">&nbsp;</p>
<td width="51%" align="right">
<p align="left"><font face="Arial">Email</font><font face="Times New
Roman">:</font><font face="Arial">  </font></td>
<td width="49%" align="left"><input type="text" name="email" size="20"></td>

<td width="51%" align="right">
<p align="left"><font face="Arial">First Name:</font></td>
<td width="49%" align="left"><input type="text" name="firstname"
<td width="51%" align="right">
<p align="left"><font face="Arial">Last Name:</font></td>
<td width="49%" align="left"><input type="text" name="lastname"
<td width="51%" align="right">
<p align="left"><font face="Arial">I know you in real life</font></td>
<td width="49%" align="left"><input type="checkbox" name="reallife"
<p><input type="submit" value="contact me"


This actual code that is on the portion of my hosting account which I
use as my test server.  In my opinion, it's much cheaper to pay for a
hosting account to use as a test server to teach myself php than it is
to pay some collage professor to teach it to you only to be slapped in
the face by having him assume you're learning php to be a freelance
coder working for a company that does freelance work.  The truth is, I
only have an interest in learning php to use in my own business and when
I get good enough, I may do some freelancing on the side on sites like
Scriptlance, but my main focus will be my own business and for anyone to
have the audacity that I plan on working for someone else my whole life
pisses me off, so that's why I'd much rather teach myself than to take a
college class on php.



PHP General Mailing List (
To unsubscribe, visit:

Reply via email to