p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: I have problem using CheckBoxes Plz Help


Message #1 by "ANIL MAHADEV" <anil_mahadev@r...> on Thu, 19 Jul 2001 11:32:01
Anyone out there who can help me with checkboxes.



I have tried the beginning php4 wrox book.



If i check a box then it displays the value i need to echo.



But When i leave it blank,it generates the following error



error @ my directory path/php/ variable not defined.



Plz help!!!



Anil Mahadev



Message #2 by "James McGuire" <j.a.mcguire@b...> on Thu, 19 Jul 2001 11:56:52 +0100
you could probably use the isset(); function. So a user could tick the box -

press the submit function and on the next page you could run something like:



if (isset($checkbox)) {



run this script;



}



because if you're telling a script to do something with a variable that

doesn't exist (user hasn't checked the checkbox) then it's obviously gonna

produce errors.



Hope it helps



Jimmy



----- Original Message -----

From: "ANIL MAHADEV" <anil_mahadev@r...>

To: "beginning php" <beginning_php@p...>

Sent: Thursday, July 19, 2001 11:32 AM

Subject: [beginning_php] I have problem using CheckBoxes Plz Help





> Anyone out there who can help me with checkboxes.

>

> I have tried the beginning php4 wrox book.

>

> If i check a box then it displays the value i need to echo.

>

> But When i leave it blank,it generates the following error

>

> error @ my directory path/php/ variable not defined.

>

> Plz help!!!

>

> Anil Mahadev

>

>



j.a.mcguire@b...


$subst('Email.Unsub')

>



Message #3 by "Stein Erik Ottersen" <eotterse@o...> on Thu, 19 Jul 2001 15:02:48 +0200
Hello Anil

The problem is that when you leave the checkbox blank the variable you try

to work with has no value and is therefore not sent by the form.



What you have to do is to check whether a variable with that name exists or

not.

You can do it like this :



    <?php



        if (isset($Choice))

             {

                echo ("no");

              }

                else

              {

                echo $Choice;

               }

    ?>

   Here you check whether or not the variable exists if it dosen't the

program prints "no" if it does it prints the value of the variable.



Stein Erik



----- Original Message -----

From: "ANIL MAHADEV" <anil_mahadev@r...>

To: "beginning php" <beginning_php@p...>

Sent: Thursday, July 19, 2001 11:32 AM

Subject: [beginning_php] I have problem using CheckBoxes Plz Help





> Anyone out there who can help me with checkboxes.

>

> I have tried the beginning php4 wrox book.

>

> If i check a box then it displays the value i need to echo.

>

> But When i leave it blank,it generates the following error

>

> error @ my directory path/php/ variable not defined.

>

> Plz help!!!

>

> Anil Mahadev

>

>

Message #4 by "Hermawan Haryanto" <hermawan@h...> on Wed, 25 Jul 2001 21:33:20
Yes, it's correct,

sometimes you can use this too :

if($nameoftickbox){

  do this syntax

}



Thanks

Hermawan Haryanto <hermawan@h...>



> you could probably use the isset(); function. So a user could tick the 

box -

> press the submit function and on the next page you could run something 

like:

> 

> if (isset($checkbox)) {

> 

> run this script;

> 

> }

> 

> because if you're telling a script to do something with a variable that

> doesn't exist (user hasn't checked the checkbox) then it's obviously 

gonna

> produce errors.

> 

> Hope it helps

> 

> Jimmy

> 

> ----- Original Message -----

> From: "ANIL MAHADEV" <anil_mahadev@r...>

> To: "beginning php" <beginning_php@p...>

> Sent: Thursday, July 19, 2001 11:32 AM

> Subject: [beginning_php] I have problem using CheckBoxes Plz Help

> 

> 

> > Anyone out there who can help me with checkboxes.

> >

> > I have tried the beginning php4 wrox book.

> >

> > If i check a box then it displays the value i need to echo.

> >

> > But When i leave it blank,it generates the following error

> >

> > error @ my directory path/php/ variable not defined.

> >

> > Plz help!!!

> >

> > Anil Mahadev




  Return to Index