Re: questions about if statements regarding a checkbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2010-10-30, at 10:28 PM, <admin@xxxxxxxxxxxxxxxxxxx> wrote:

> 
> 
> <input type=checkbox name=test>
> 
> 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:Ben@xxxxxxxxxxxx] 
> Sent: Saturday, October 30, 2010 10:05 PM
> To: php-general@xxxxxxxxxxxxx
> Subject:  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
> 

<input type=checkbox name=test value=1>
<input type=checkbox name=test value=2>
<input type=checkbox name=test value=3>

<?php

$Val=$_POST['test'];

switch($Val){
  case 1:
    // do something
    break;

  case 2:
    //do something else
    break;

  default:
     //another process

}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux