More clarification: I have a checkbox with name="agree" in my register form, and the user must mark this value="agree" to complete the process of registration, if this checkbox not marked an error message will appear to the user. As a test I tried to submit the form without mark this checkbox but I found this INDEX error appeared saying: [ Notice: Undefined index: agree in ] even the error message for the user has appeared too.
I have a checkbox and radio fields in my form, these fields are optional. So when I submit my form and these values are empty I get an INDEX error. Is there any way to avoid that error without using error_reporting(0) fuction:
<form action="" method="post">
<div class="checkbox">
<label>
<input type="checkbox" name="agree" value="agree">
</label>
</div>
</form>
<?php
if (isset($_POST['submit'])) {
$agree = $_POST['agree'];
}
?>