Help PHP and HTML Checkboxes - php

I need help working with Checkboxes and PHP. I'm just trying to determine a value on whether the checkbox is checked or not with PHP.
Example:
<?php
include ("inc/conf.php");
$id = $_SESSION['id'];
if(isset($_POST['subfrm'])){
$gtid = $_REQUEST['tid'];
$ch1 = $_REQUEST['ch1'];
if($ch1 == "ON"){
$gch1 = "Y";
} else {
$gch1 = "N";
}
$ch2 = $_REQUEST['ch2'];
if($ch2 == "ON"){
$gch2 = "Y";
} else {
$gch2 = "N";
}
mysql_query("UPDATE SET ctable ch1='$gch1', ch2='$gch2' WHERE id='$gtid'");
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="tid" value="<?php echo $id; ?>" />
<input type="checkbox" name="ch1" />Hats
<input type="checkbox" name="ch2" />Watches
<textarea name="thetext"></textarea>
<input type="submit" name="subfrm" value="PUNCH ME" />
</form>

if(isset($_REQUEST["ch1"])){
$gch1 = "Y";
} else {
$gch1 = "N";
}
if(isset($_REQUEST["ch2"])){
$gch2 = "Y";
} else {
$gch2 = "N";
}
You don't need to check to see what the value is, because it will not submit any data whatsoever if it isn't checked, and it will submit a value of on if it is.

Try this:
<?php
$ch1 = isset($_REQUEST['ch1']);
If the check box wasn't checked, its corresponding variable won't show up in the request.

Through this together. It will let you know which checkbox was selected and it will also retain the check on form submit.
<?php
$message = '';
$ch1_checked = false;
$ch2_checked = false;
if(isset($_POST['submit_button'])) {
// Form was submitted
$ch1_checked = isset($_POST['ch1']);
$ch2_checked = isset($_POST['ch2']);
if($ch1_checked && $ch2_checked) {
$message .= 'Both were checked.';
} else if($ch1_checked) {
$message .= 'Checkbox 1 was checked.';
} else if($ch2_checked) {
$message .= 'Checkbox 2 was checked.';
} else {
$message .= 'Neither were checked.';
}
}
?>
<?php echo $message; ?>
<form id="my_form" action="test.php" method="post">
<input type="checkbox" name="ch1" value="ch1" <?php if($ch1_checked) echo 'checked'; ?> />Checkbox 1<br />
<input type="checkbox" name="ch2" value="ch2" <?php if($ch2_checked) echo 'checked'; ?> />Checkbox 2<br />
<input type="submit" name="submit_button" value="Go!" />
</form>

Related

PHP session array and input validation

Currently I am sending error messages and storing the value of my input fields in sessions.
Form example
<label class="errormsg"><?php echo $_SESSION['msgProductPrice']; unset($_SESSION['msgProductPrice']); ?></label>
<input type="text" name="product_price" value="<?php echo $_SESSION['val_ProductPrice']; unset($_SESSION['val_ProductPrice']); ?>" />
PHP
$Price = $_POST['product_price'];
$errorcount = 0;
if(empty($Price) === true){
$PriceErrormsg = "empty";
$errorcount++;
}
if($errorcount === 0) {
// success
} else {
$_SESSION['val_ProductPrice'] = $Price;
$_SESSION['msgProductPrice'] = $PriceErrormsg;
}
This works perfectly with one of a kind input field. If I try with multiple input fields with the same name, it doesn't work.
Form example
<label class="errormsg"><?php echo $_SESSION['msgProductAmount']; unset($_SESSION['msgProductAmount']); ?></label>
<input type="text" name="product_amount[]" value="<?php echo $_SESSION['val_ProductAmount']; unset($_SESSION['val_ProductAmount']); ?>" />
<label class="errormsg"><?php echo $_SESSION['msgProductAmount']; unset($_SESSION['msgProductAmount']); ?></label>
<input type="text" name="product_amount[]" value="<?php echo $_SESSION['val_ProductAmount']; unset($_SESSION['val_ProductAmount']); ?>" />
This is where I'm unsure on how to validate all the input fields, how to keep the value in each input field when you hit submit and how to send an errormsg about each field?
PHP
$Amount= $_POST['product_amount'];
$errorcount = 0;
if(empty($Amount) === true){
$AmountErrormsg = "empty";
$errorcount++;
}
if($errorcount === 0) {
// success
} else {
$_SESSION['val_ProductAmount'] = $Amount;
$_SESSION['msgProductAmount'] = $AmountErrormsg;
}
If I understand your problem, multiple product amounts are being submitted, and you want to validate each one individually and display the error message next to the appropriate textbox?
Because you are receiving an array of values, you need to create a corresponding array of error messages.
It's a while since I've done any PHP, so this might not be 100% correct, but I think you need something along these lines...
$AmountErrorMessage = Array();
foreach ($Amount as $key => $value) {
if (empty($value)) {
$AmountErrorMessage[$key] = 'empty';
}
}
if ($AmountErrorMessage->count() > 0) {
// success
} else {
$_SESSION['val_ProductAmount'] = $Amount;
$_SESSION['msgProductAmount'] = $AmountErrorMessage;
}
You would then also need to iterate through the array in order to generate the HTML for your form, creating a label and input box for each value submitted.
This code help you to do it as per your wish..
<?php
session_start();
?>
<html>
<head>
<title></title>
<style>
.errormsg{
color:red;
}
</style>
</head>
<body>
<?php
if(isset($_POST['product_amount']))
{
$errorcount = 0;
for($i=0;$i<count($_POST['product_amount']);$i++){
$Amount[$i] = $_POST['product_amount'][$i];
if(empty($Amount[$i]) === true){
$_SESSION['msgProductAmount'][$i] = "empty";
$errorcount++;
}
else
$_SESSION['val_ProductAmount'][$i] = $Amount[$i];
}
if($errorcount === 0) {
unset($_SESSION['msgProductAmount']);
echo "success";
}
}
?>
<form action="" method="POST">
<?php
$cnt = 10;
for($i=0;$i<$cnt;$i++){
?>
<input type="text" name="product_amount[<?=$i?>]" value="<?php echo isset($_SESSION['val_ProductAmount'][$i]) ? $_SESSION['val_ProductAmount'][$i] : '';?>" />
<label class="errormsg"><?php echo $res = isset($_SESSION['msgProductAmount'][$i]) ? $_SESSION['msgProductAmount'][$i] : '' ; ?></label>
<br/>
<?php
}
?>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
<?php
unset($_SESSION['msgProductAmount'],$_SESSION['val_ProductAmount']);
?>

PHP - Can not access the checkbox value that has been checked

For my databases project I am doing this form where a user can select the information he wants and it will be displayed on a html page. For the time being I am implementing only the checkboxes where I am encountering a problem.
The problem is that when I check the checkboxes (for my current implementation I am only interested in the case where the user checks "Location"+ "Pipe-Type" + "Amount") in my action page "fe_page2.php", the if condition that checks to see if the checkboxes are checked is never being reached instead it always goes to the else condition. The code is provided below.
This is my basic html page:
<html>
<head>
<title>Flow Element</title>
</head>
<body>
<h1 style="margin-left: 450px">Retrieve Flow Element Information</h1>
<hr>
<form action="fe_page2.php" method="post">
All Times:
<input type="checkbox" name="alltimes" onchange="changeFields()"><br><br>
Start Date:
<input type="date" name="startdate" id="startdate">
Start Time:
<input type="time" name="starttime" id="starttime"><br><br>
Same Time:
<input type="checkbox" name="sametime" id = "sametime" onchange="sameFields()"><br><br>
End Date:
<input type="date" name="enddate" id="enddate">
End Time:
<input type="time" name="endtime" id="endtime"><br><br>
<h3> Select fields of output</h3>
<hr>
Pipe Key: <input type="text" name="pipepirmary" id="pipekey"><br>
<input type="checkbox" name="pipelocation" id="pipeLocation" value="value1" >
Location<br>
<input type="checkbox" name="Pipe-Type" id="pipetype" value="value2">
Pipe-Type<br>
<input type="checkbox" name="amount" id="amount" value="value3">
Amount<br><br>
Flow Element:<input type="text" name="fepirmarykey" id="fekey"/><br>
<input type="checkbox" name="flow" id="flo">
Flow<br>
<input type="checkbox" name="temperature" id="temp">
Temperature<br>
<input type="checkbox" name="pressure" id="pres">
Pressure<br><br>
<input type="submit">
</form>
<script>
function changeFields() {
if(document.getElementById("startdate").disabled == false){
document.getElementById("startdate").disabled = true;
document.getElementById("starttime").disabled = true;
document.getElementById("enddate").disabled = true;
document.getElementById("endtime").disabled = true;
document.getElementById("sametime").disabled = true;
if(document.getElementById("sametime").checked = true){
document.getElementById("sametime").checked = false;
}
document.getElementById("startdate").value = null;
document.getElementById("starttime").value = null;
document.getElementById("enddate").value = null;
document.getElementById("endtime").value = null;
}
else{
document.getElementById("startdate").disabled = false;
document.getElementById("starttime").disabled = false;
document.getElementById("enddate").disabled = false;
document.getElementById("endtime").disabled = false;
document.getElementById("sametime").disabled = false;
}
}
function sameFields() {
if(document.getElementById("enddate").disabled == false){
document.getElementById("enddate").disabled = true;
document.getElementById("endtime").disabled = true;
document.getElementById("enddate").value = null;
document.getElementById("endtime").value = null;
}
else{
document.getElementById("enddate").disabled = false;
document.getElementById("endtime").disabled = false;
}
}
</script>
</body>
</html>
This is the php page fe_page2.php
<?php
require('dbconf.inc');
db_connect();
print"<pre>";
print_r($_POST);
print"</pre>";
$pipelocation = $_POST[pipelocation];
$pipetype = $_POST[Pipe-Type];
$pipeamount = $_POST[amount];
if($pipelocation=='value1' && $pipetype == 'value2' && $pipeamount == 'value3'){
$qrySel="SELECT `Pipe_ID`, `Location`, `Amount`, `PipeType` FROM pipe order by Pipe_ID desc";
$resSel = mysql_query($qrySel);
if($resSel){
while($rowpipe = mysql_fetch_array($resSel, MYSQL_ASSOC)){
echo "Pipe ID:{$rowpipe['Pipe_ID']} <br> ".
"Location: {$rowpipe['Location']} <br> ".
"Amount: {$rowpipe['Amount']} <br>".
"PipeType: {$rowpipe['PipeType']} <br>".
"--------------------------------<br>";
}
echo "Fetched Data Successfully!\n";
}
}
else{
echo"never went in!";
}
db_close();
?>
I have tried different things such as
if(isset($pipelocation) && isset($pipetype) && isset($pipeamount)){
.....
}
and removing the value from html page and using the following piece of code:
if($pipelocation == 'on' && $pipetype == 'on' && $pipeamount == 'on'){
...
}
But still no luck...
Any help would be appreciated.
The code that is presented is purely my work but does include pieces of code that comes from the provided reference below:
https://www.youtube.com/watch?v=LZtXYa9eGGw
You missed the quotations here:
$pipelocation = $_POST['pipelocation'];
$pipetype = $_POST['Pipe-Type'];
$pipeamount = $_POST['amount'];

php get the value from hidden field after redirect

member.php
<?php
if(isset($_POST['submit']))
{
$membername = $_POST['membername'];
if(empty($membername))
{
$errors .= "Please enter member name<br />";
}
if($errors)
{
$action = $_POST['submit'];
echo $errors;
displayForm();
}
else
{
?>
<input type="hidden" name="mname" value="<?php echo $_POST['membername']; ?>" />
<?php
$action = $_POST['submit'];
header("Location: commit.php?action=$action");
exit();
}
}
else
{
displayForm();
}
?>
<?php
function displayForm()
{
?>
<form action = "member.php" action="post">
Member Name <input type="text" name="membername" value="<?php if(isset($row['name'])) echo $row['name'];
else echo ''; ?>" /><br /><input type="text" name="membername" value=
<input type="submit" name="submit" name="add" />
</form>
<?php
}
?>
Commit.php
<?php
echo $_POST['mname']; //HERE
?>
I want to pass the hidden value from member.php. When I run commmit.php, I want to get hidden field value. However, the error is the following:
**Undefined index: mname in member.php in commit.php.
What am I doing wrong?

Invite PHP form Using External Text File

REVISED: I'm trying to process a form, validates it and sends emails to these recipients.
<form>
<input name="name1"> <input email="email1">
<input name="name2"> <input email="email2">
<input name="name3"> <input email="email3">
....
<input type="submit" name="submit">
</form>
What I was trying to do was rather than doing a multiple inputs, I'd use the for loop like so..
<form method=GET action="">
<?php
for($i = 1; $i <= 10; $i++)
{
echo 'First name: <input name="firstname[$i]">';
echo 'Last name:<input name="lastname[$i]">';
echo 'Email: <input name="email[$i]"><br>';
}
?>
<input type="submit" name="Submit" value="Submit">
</form>
<?php
$msg = "a message";
$subject = "a subject";
foreach($_POST['email'] as $email){
mail($email, $subject,$msg,'From: ' . $_POST['sendername'] . "\n\r" );
}
?>
My question is I'm not sure what's the best way to validate these fields. Any pointers would be helpful. I'm not a programmer I'm just a beginner.
EDIT
The answer below is for the OP's original question before his EDIT.
Original question: https://stackoverflow.com/revisions/18454820/1
This line was problematic:
echo '<input type="text" name="firstname[]" size="20" value=".(if (isset($_POST['firstname'][$i])) { print htmlspecialchars($_POST['firstname'][$i]); })." />';
and was replaced by: (to get it working)
echo '<input type="text" name="firstname[]" size="20" />';
Plus, I replaced your form action to action=""
Working code:
<!DOCTYPE html>
<html>
<head>
<title>PHP FORM </title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="container">
<?php
// Print some introductory text:
print '<h2>Party Invitation Form</h2>
<p>Please enter list of people with first name, last name and email address to get an invitation by email.</p>';
// Check if the form has been submitted:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$problem = FALSE; // No problems so far.
// Check for each value...
for ($i = 0; $i < count($_POST['email']); $i++) {
if (empty($_POST['firstname'][$i])) {
$problem = TRUE;
echo '<input type="text" name="firstname[]" size="20" />';
}
if (empty($_POST['lastname'][$i])) {
$problem = TRUE;
}
if (empty($_POST['email'][$i]) || (substr_count($_POST['email'][$i], '#') != 1) ) {
$problem = TRUE;
}
}
if (!$problem) { // If there weren't any problems...
// Print a message:
echo '<p><b>Thank you for registering! We will send each one an invitation: <b> </b></p>';
for ($i = 0; $i < count($_POST['email']); $i++) {
echo $_POST['firstname'][$i]." ".$_POST['lastname'][$i]." ".$_POST['email'][$i]." <br/>";
// Send the email:
$body = "Thank you {$_POST['firstname'][$i]} for registering with the blah blah blah blah!";
mail($_POST['email'][$i], 'Party Invitation', $body, 'From: email#example.com');
}
// Clear the posted values:
$_POST = array();
} else { // Forgot a field.
print '<p id="error">* Required field! Please try again. Thank you.</p>';
}
} // End of handle form IF.
// Create the form:
?>
<form action="" method="post">
<table>
<tr>
<td>First name:</td>
<td>Last name:</td>
<td>Email:</td>
</tr>
<?php for ($i = 0; $i < 2; $i++) { ?>
<tr>
<td><?php if ($problem == TRUE) { echo '<p id="error">*'; } ?>
<input type="text" name="firstname[]" size="20" value="<?php if (isset($_POST['firstname'][$i])) { print htmlspecialchars($_POST['firstname'][$i]); } ?>" />
</td>
<td><?php if ($problem == TRUE) { echo '<p id="error">*'; } ?>
<input type="text" name="lastname[]" size="20" value="<?php if (isset($_POST['lastname'] [$i])) { print htmlspecialchars($_POST['lastname'][$i]); } ?>" />
</td>
<td><?php if ($problem == TRUE) { echo '<p id="error">*'; } ?><input type="text" name="email[]" size="20" value="<?php if (isset($_POST['email'][$i])) { print htmlspecialchars($_POST['email'][$i]); } ?>" />
</td>
</tr>
<?php } ?>
<tr><td><p><input type="submit" class="button" name="submit" value="Register!" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>

POST checkbox value to email?

I have a simple example of check box's which remember what has been selected after the form has been submitted and there is an error.
That part works great... but, I would like to post the resultant 'checked' boxes to my forms mail function.
What I have now only reports if its checked or unchecked I would prefer to have the checked box's 'value' without the unchecked box even registering.
<?php
$CB_1 = 'unchecked';
$CB_2 = 'unchecked';
$CB_3 = 'unchecked';
$CB_4 = 'unchecked';
$CB_5 = 'unchecked';
if (isset($_POST['submit'])) {
if (isset($_POST['CB_1'])) {$CB_1 = $_POST['CB_1'];
if ($CB_1 == 'item_01') {$CB_1 = 'checked';}
}
if (isset($_POST['CB_2'])) {$CB_2 = $_POST['CB_2'];
if ($CB_2 == 'item_02') {$CB_2 = 'checked';}
}
if (isset($_POST['CB_3'])) {$CB_3 = $_POST['CB_3'];
if ($CB_3 == 'item_03') {$CB_3 = 'checked';}
}
if (isset($_POST['CB_4'])) {$CB_4 = $_POST['CB_4'];
if ($CB_4 == 'item_04') {$CB_4 = 'checked';}
}
if (isset($_POST['CB_5'])) {$CB_5 = $_POST['CB_5'];
if ($CB_5 == 'item_05') {$CB_5 = 'checked';}
}
}
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[a-z0-9]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "E-mail address not valid.";
}
} else {
$error .= "E-mail address is required.";
}
if (empty($error)) {
$from = 'From: '. #TEST .' <'. $email .'>';
$to = "someone#company.com";
$subject = "CHECKBOX TEST";
$content = "
checkbox selections:
check box 01: $CB_1
check box 02: $CB_2
check box 03: $CB_3
check box 04: $CB_4
check box 05: $CB_5
";
$success = mail($to,$subject,$content,$from);
}
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<?php if (!empty($error)) echo $error ?>
<br><br><br>
e-mail: <input type="text" name="email" value="<?php if (isset ($_POST {'email'})) { echo $_POST['email']; } ?>" />
<P>
<input type="checkbox" name="CB_1" value="item_01" <?PHP echo $CB_1; ?> /> Item 01
<input type="checkbox" name="CB_2" value="item_02" <?PHP echo $CB_2; ?> /> Item 02
<input type="checkbox" name="CB_3" value="item_03" <?PHP echo $CB_3; ?> /> Item 03
<input type="checkbox" name="CB_4" value="item_04" <?PHP echo $CB_4; ?> /> Item 04
<input type="checkbox" name="CB_5" value="item_05" <?PHP echo $CB_5; ?> /> Item 05
<P>
<input type="submit" name="submit" value="Submit"></input>
</form>
I know this may not necessarily answer the question but a way you could make your code more efficiant is do this.
for($i=1; $i<=5;$i++)
{
if(isset($_POST['submit'])&& isset($_POST['CB_'.$i]) && $CB_.$i=='item_0'.$i)
{
$CB_.$i = $_POST['CB_'.$i];
$CB_.$i = 'checked';
}
}
If you fix it that way it may also make it easier for us to debug.
okay, I found a way to do what I wanted but I'm fairly sure it's not the way someone who has real experience with PHP would do it. Any suggestions?
redelman431, thanks for your suggestion but it was really too advanced for my skill level.
<?php
if(isset($_POST['item_01'])) {$item_01 = 'Item 01';}
if(isset($_POST['item_02'])) {$item_02 = 'Item 02';}
if(isset($_POST['item_03'])) {$item_03 = 'Item 03';}
if(isset($_POST['item_04'])) {$item_04 = 'Item 04';}
if(isset($_POST['item_05'])) {$item_05 = 'Item 05';}
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[a-z0-9]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "E-mail address not valid.";
}
} else {
$error .= "E-mail address is required.";
}
if (empty($error)) {
$from = 'From: '. #TEST .' <'. $email .'>';
$to = "someone#company.com";
$subject = "CHECKBOX TEST";
$content = "
checkbox selections:
checked box's: $item_01 $item_02 $item_03 $item_04 $item_05
";
$success = mail($to,$subject,$content,$from);
}
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<span style="color: red;"><?php if (!empty($error)) echo $error ?></span>
<br><br><br>
e-mail: <input type="text" name="email" value="<?php if (isset ($_POST {'email'})) { echo $_POST['email']; } ?>" />
<P>
<input type="checkbox" name="item_01" value="Item 01"
<?php if(isset($_POST['item_01'])) { echo 'checked'; } ?> /> Item 01
<input type="checkbox" name="item_02" value="Item 02"
<?php if(isset($_POST['item_02'])) { echo 'checked'; } ?> /> Item 02
<input type="checkbox" name="item_03" value="Item 03"
<?php if(isset($_POST['item_03'])) { echo 'checked'; } ?> /> Item 03
<input type="checkbox" name="item_04" value="Item 04"
<?php if(isset($_POST['item_04'])) { echo 'checked'; } ?> /> Item 04
<input type="checkbox" name="item_05" value="Item 05"
<?php if(isset($_POST['item_05'])) { echo 'checked'; } ?> /> Item 05
<P>
<input type="submit" name="submit" value="Submit"></input>
</form>
I found what I was looking for I suppose in the way of an array which I think 'redelman431' was trying to get me to do but it didn't make any sense to me at the time.
I then stumbled onto another array by 'David BĂ©langer' that for some reason made more sense to me so I used it into my check box's and it works fabulously.
the new problem is that I cant get the check box's that have been checked to remember that if there is an error elsewhere on the page which is a disaster as my final form has a ton of them.
Any ideas?
<?php
# Default Vars
$_group_01 = '';
if(isset($group_01) === TRUE){
# Is Array ?
if(is_array($group_01) === TRUE){
# Count
$c = count($group_01);
# Loop
for($i=0; $i < $c; $i++){
$_group_01.= (isset($group_01[$i]) === TRUE ? $group_01[$i] : '').($i == ($c-1) ? '' : ($i == $c-2 ? ' and ' : ', '));
}
}
}
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[a-z0-9]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "E-mail address not valid.";
}
} else {
$error .= "E-mail address is required.";
}
if (empty($error)) {
$from = 'From: '. TEST .' <'. $email .'>';
$to = "someone#company.com";
$subject = "CHECKBOX TEST";
$content = "
checkbox selections:
Items Checked: $_group_01
";
$success = mail($to,$subject,$content,$from);
}
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<span style="color: red;"><?php if (!empty($error)) echo $error ?></span>
<br><br><br>
e-mail: <input type="text" name="email" value="<?php if (isset ($_POST {'email'})) { echo $_POST['email']; } ?>" />
<P>
<input type="checkbox" name="group_01[]" value="Item 01"
<?php if(isset($_POST['group_01'])) { echo 'checked'; } ?> />Item 01
<input type="checkbox" name="group_01[]" value="Item 02"
<?php if(isset($_POST['group_01'])) { echo 'checked'; } ?> />Item 02
<input type="checkbox" name="group_01[]" value="Item 03"
<?php if(isset($_POST['group_01'])) { echo 'checked'; } ?> />Item 03
<input type="checkbox" name="group_01[]" value="Item 04"
<?php if(isset($_POST['group_01'])) { echo 'checked'; } ?> />Item 04
<input type="checkbox" name="group_01[]" value="Item 05"
<?php if(isset($_POST['group_01'])) { echo 'checked'; } ?> />Item 05
<P>
<input type="submit" name="submit" value="Submit"></input>
</form>

Categories