Jump to content

check box question


eurob

Recommended Posts

part of my html

<form action="process.php" method="post">
Check box field: <input name="showit[]" type="checkbox"  value="whatever">
<input type="submit">

 

//process.php

<?php 
$showit = $_POST['showit']
?>

If I don't check the check box I get the error 'undefined index'.
How can I still capture the check box value, regardless if I checked it or not? 

Thanks,
robert

Link to comment
https://forums.phpfreaks.com/topic/83550-check-box-question/
Share on other sites

process.php

 

<?php
if ( isset($_POST['showit']) ) {
    $showit = $_POST['showit']
}

 

Undefined index is only a notice, nothing fatal. You can ignore those, but if you want to program correctly, you need to test if a variable exists before working with it directly.

 

PhREEEk

Link to comment
https://forums.phpfreaks.com/topic/83550-check-box-question/#findComment-425104
Share on other sites

Archived

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

×
×
  • Create New...

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.