Re: [PHP] questions about if statements regarding a checkbox
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, ad...@buskirkgraphics.com 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. print_r($_POST); you can see every position of the array passed and validate they are passing as intended. 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 if(isset($_POST['reallife'])) { print_r($_POST); } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Sunday, October 31, 2010 8:26 AM To: php-general@lists.php.net 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. [php_code] $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $email = $_POST['email']; if($_POST['reallife'] == "on") { $to = 'b...@benbrent.com'; $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 = 'b...@benbrent.com'; $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:' . $...@benbrent.com); } header ("location:thankyoupage") [/php_code] [html_code] Contact Form Email: First Name: Last Name: I know you in real life [/html_code] 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. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
thanks for your help. I just retested my code and even though it didn't work, I found the reason it wasn't working was because I had an unneeded space between the "if" and the rest of the if statement. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
At 10:05 PM -0400 10/30/10, Ben Brentlinger wrote: hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben Ben: Here you go: http://php1.net/b/form-checkbox/ and if you want to make it sticky: http://php1.net/b/form-checkbox1/ Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] questions about if statements regarding a checkbox
I placed an example of your code on my site. I simply pasted exactly what you had, minus the actual mailing portion. If you check the box you will see the array, if you do not check the box no array. http://www.richardbuskirk.com/blunk.php Forgive my prior post, I had not woke up yet. So the wording is missing things though, yet not put to email mid sentence. Code from site. Contact Form Email: First Name: Last Name: I know you in real life Richard L. Buskirk -Original Message- From: ad...@buskirkgraphics.com [mailto:ad...@buskirkgraphics.com] Sent: Sunday, October 31, 2010 10:37 AM To: 'Ben Brentlinger'; php-general@lists.php.net Subject: RE: [PHP] questions about if statements regarding a checkbox 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. print_r($_POST); you can see every position of the array passed and validate they are passing as intended. 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 if(isset($_POST['reallife'])) { print_r($_POST); } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Sunday, October 31, 2010 8:26 AM To: php-general@lists.php.net 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. [php_code] $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $email = $_POST['email']; if($_POST['reallife'] == "on") { $to = 'b...@benbrent.com'; $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 = 'b...@benbrent.com'; $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:' . $...@benbrent.com); } header ("location:thankyoupage") [/php_code] [html_code] Contact Form Email: First Name: Last Name: I know you in real life [/html_code] 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. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] questions about if statements regarding a checkbox
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. print_r($_POST); you can see every position of the array passed and validate they are passing as intended. 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 if(isset($_POST['reallife'])) { print_r($_POST); } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Sunday, October 31, 2010 8:26 AM To: php-general@lists.php.net 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. [php_code] $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $email = $_POST['email']; if($_POST['reallife'] == "on") { $to = 'b...@benbrent.com'; $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 = 'b...@benbrent.com'; $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:' . $...@benbrent.com); } header ("location:thankyoupage") [/php_code] [html_code] Contact Form Email: First Name: Last Name: I know you in real life [/html_code] 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. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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. [php_code] $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $email = $_POST['email']; if($_POST['reallife'] == "on") { $to = 'b...@benbrent.com'; $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 = 'b...@benbrent.com'; $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:' . $...@benbrent.com); } header ("location:thankyoupage") [/php_code] [html_code] Contact Form Email: First Name: size="20"> Last Name: size="20"> I know you in real life size="20"> [/html_code] 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. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
Hello Ben, You should use isset: if (isset($_POST['check'])) { // The checkbox is checked } else { // It's unchecked } -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion - Original message - From: Ben Brentlinger To: php-general@lists.php.net Date: Sunday, October 31, 2010, 4:05:06 AM Subject: [PHP] questions about if statements regarding a checkbox hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
What is the code you're using now? You have a syntax error, but without seeing the code, we are all left to guessing what the problem could be. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Ben Brentlinger" Date: Sun, Oct 31, 2010 03:56 Subject: [PHP] questions about if statements regarding a checkbox To: I tried that, but I'm getting the syntax error that says "unexpected T_IF". Probably because I'm trying to process this information directly in an email rather letting a mysql database handle the data, which I find harder to set up when writing a script from scratch than it would be to code a php script to send the data in an email. On 10/30/2010 22:28, ad...@buskirkgraphics.com wrote: > > > > If check it will submit the value of 'on' > > So > > If($_POST['test'] == "on') > { > Do this > }else{ > Do this > } > > > Richard L. Buskirk > > > -Original Message- > From: Ben Brentlinger [mailto:b...@benbrent.com] > Sent: Saturday, October 30, 2010 10:05 PM > To: php-general@lists.php.net > Subject: [PHP] questions about if statements regarding a checkbox > > hello, > > I'd like to know the proper code to use in a php script that processes a > form with a checkbox in order to send one email if the checkbox has been > checked and another email if the checkbox hasn't. I tried if($check == > true) and I tried putting the word "true" in double quotes, and both of > them caused the "unexpected variable" syntax error. The only problem > is, all I could think to use was that line of code I just used, I'm not > sure what the proper syntax is for checkbox when using the if statement > to send one email when the checkbox is checked and a different email > when it's not checked. I'm wanting to send an email to the site admin > with the information given by the person who filled out the form that > contains the checkbox. > > > Thanks, > > Ben > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
I tried that, but I'm getting the syntax error that says "unexpected T_IF". Probably because I'm trying to process this information directly in an email rather letting a mysql database handle the data, which I find harder to set up when writing a script from scratch than it would be to code a php script to send the data in an email. On 10/30/2010 22:28, ad...@buskirkgraphics.com wrote: If check it will submit the value of 'on' So If($_POST['test'] == "on') { Do this }else{ Do this } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Saturday, October 30, 2010 10:05 PM To: php-general@lists.php.net Subject: [PHP] questions about if statements regarding a checkbox hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
On 2010-10-30, at 10:28 PM, wrote: > > > > > If check it will submit the value of 'on' > > So > > If($_POST['test'] == "on') > { > Do this > }else{ > Do this > } > > > Richard L. Buskirk > > > -Original Message- > From: Ben Brentlinger [mailto:b...@benbrent.com] > Sent: Saturday, October 30, 2010 10:05 PM > To: php-general@lists.php.net > Subject: [PHP] questions about if statements regarding a checkbox > > hello, > > I'd like to know the proper code to use in a php script that processes a > form with a checkbox in order to send one email if the checkbox has been > checked and another email if the checkbox hasn't. I tried if($check == > true) and I tried putting the word "true" in double quotes, and both of > them caused the "unexpected variable" syntax error. The only problem > is, all I could think to use was that line of code I just used, I'm not > sure what the proper syntax is for checkbox when using the if statement > to send one email when the checkbox is checked and a different email > when it's not checked. I'm wanting to send an email to the site admin > with the information given by the person who filled out the form that > contains the checkbox. > > > Thanks, > > Ben > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] questions about if statements regarding a checkbox
If check it will submit the value of 'on' So If($_POST['test'] == "on') { Do this }else{ Do this } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Saturday, October 30, 2010 10:05 PM To: php-general@lists.php.net Subject: [PHP] questions about if statements regarding a checkbox hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about if statements regarding a checkbox
On Sat, Oct 30, 2010 at 10:05 PM, Ben Brentlinger wrote: > hello, > > I'd like to know the proper code to use in a php script that processes a > form with a checkbox in order to send one email if the checkbox has been > checked and another email if the checkbox hasn't. I tried if($check == > true) and I tried putting the word "true" in double quotes, and both of them > caused the "unexpected variable" syntax error. The only problem is, all I > could think to use was that line of code I just used, I'm not sure what the > proper syntax is for checkbox when using the if statement to send one email > when the checkbox is checked and a different email when it's not checked. > I'm wanting to send an email to the site admin with the information given > by the person who filled out the form that contains the checkbox. > // checkboxes are only set if checked if (isset($_GET['checkbox_name'])) { // checkbox is checked, so send one mail mail($to = 'o...@email.com', $subject = 'Really cool email'); } else { // checkbox isn't checked, so send a different email mail($to = 'differ...@email.com', $subject = 'Just as cool email'); } Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] questions about if statements regarding a checkbox
hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php