Potreban mi je checkbox na kontakt formi i želim to uraditi kroz php i napraviti validaciju kroz php.
Uradila sam to na sljedeći način:
<div class="form-check">
<input class="form-check-input" type="checkbox" name="terms" value="1" id="terms">
<label class="form-check-label">
<?php echo (empty($_POST['terms'])) ? '':'checked' ?> Pročitao/la sam uvjete privatnosti i slažem se.
</label>
<p class='terms'><?= $terms_error ?></p>
</div>
Validacija…
if (empty($_POST["terms"])) {
$terms_error = "If you agee to the terms, please check the box below";
} else {
$terms = ($_POST["terms"]);
}
I sada kada testiram na XAMPP pokazuje mi
Notice : Undefined variable: terms_error in C:\xampp\htdocs--\contact.php on line 122
A kada kliknem na dugme submit pokajvi se normalno poruka “If you agee to the terms, please check the box below” i onda nestane ova napomena “Undefined variable” ako uradim refresh opet se pojavi.
Bilo kakva pomoć je dobro došla. Hvala.