Jump to content

Archived

This topic is now archived and is closed to further replies.

scheols

um inputes quick question

Recommended Posts

so um you know how you have button inputs and you can do a check with if statement

if(isset($buttonname)){
//do somthen
}else{
//do somthen

can you do this for radio buttons? and how does it work with check boxes?

the isset check

Share this post


Link to post
Share on other sites
ok here you go

a simple form with three check boxes with the isset submit
[code=php:0]<?php
if (isset(submit) {
    if (!$test) { //the name of the checkbox
      echo "You did not check a box";
      exit;
    }
//do something
}
?>
<form method="POST" action="whatever.php">
<input type="checkbox" name="test" value="test"> test<br>
<input type="checkbox" name="test" value="test2"> test2<br>
<input type="checkbox" name="test" value="test3"> test3<br>
<p><input type="submit" value="Submit" name="submit"></p>
</form>[/code]

Hope this helps,
Tom

Share this post


Link to post
Share on other sites
Actually, you need to give the checkboxes different names, otherwise you will only get the value of the last one, unless you call them "test[]" for example, then you get an array with their values. With radio buttons, you give each radio button in the set the same name but different values, and the variable with the corresponding name will have the value of whichever one is selected.

Share this post


Link to post
Share on other sites

×

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.