Hi,
i'd really appreciate it if one of you great 🙂 people could help me out...
Basically i'm just trying to write example programmes to bolster my php skills, BUT!
Here ive got a program which I would like a user to put a tick into a couple of checkboxes and simply output a number '1' for the first box and a '2' for the second and a number '3' if both boxes are checked, if they enter nothing at all an error message will appear. Sounds easy right?
At the moment the error is being generated when the program is run but will disappear when both are checked.....I'll get my coat.
Heres the code :
<html>
<head>
<title>Untitled Document</title>
<?php
$added = $checkbox + $checkbox2;
$var;
if(submit) {
if(!isset($checkbox,$checkbox2)) {
echo ("Enter Something!");
}
if($checkbox) {
$var=$checkbox;
}
if ($checkbox2) {
$var=$checkbox2;
}
if (isset($checkbox,$checkbox2)) {
$var=$added;
}
}
?>
</head>
<body>
<p>
</p>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<input type="checkbox" name="checkbox" value=1>
option 1<br>
<input type="checkbox" name="checkbox2" value=2>
option 2 <br>
<input type="submit" name="submit" value="Submit" />
</form><br><br>
<?php
if (!isset($var)) {
echo (""); }
else echo ($var);
?>
<p> </p>
</body>
</html>