Hej,
Mam pewien problem ze zmienną w PHP ($regulamin). Zmienna jest zdefiniowana a pomimo to, wywala mi Notice o treści:
Notice: Undefined index: regulamin in C:\xampp\htdocs\test\index.php on line 10
Problem mam tylko z jedną zmienna która odnosi się do checkbox'a. Co dziwne to to, że w kursie jest dokładnie tak samo i mimo tego, że ma żadnego błędu.
<?php
$email = '';
$password = '';
$regulamin = '';
$errorEmail = '';
$errorPassword = '';
$errorRegulamin = '';
if( isset( $_POST['send'])){
$email = $_POST['email'];
$regulamin = $_POST['regulamin'];
$password = $_POST['password'];
if ( ! $email ){
$errorEmail = 'Uzupełnij email!';
}
if ( ! $password ){
$errorPassword = 'Uzupełnij hasło';
}
elseif ( $password && strlen($password) < 8 ){
$errorPassword = 'Hasło musi składać się z przynajmniej 8 znaków';
}
if ( $regulamin != 'on' ){
$errorRegulamin = 'Musisz Zaakceptować regulamin !';
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form class="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div class="required field">
<?php if ( $errorEmail != null) { ?>
<span> <?php echo $errorEmail; ?> </span>
<?php } ?>
<label>Email</label>
<input type="email" name="email" value="" placeholder="Mail adress"><br><br>
</div>
<div class="required field">
<?php if ( $errorPassword != null) { ?>
<span> <?php echo $errorPassword; ?> </span>
<?php } ?>
<label>password</label>
<input type="password" name="password" value="" placeholder="Password"><br><br>
</div>
<div class="required field">
<?php if ( $errorRegulamin != null) { ?>
<span> <?php echo $errorRegulamin; ?> </span>
<?php } ?>
<label>Regulamin</label>
<input type="checkbox" name="regulamin"> warunki korzystania<br>
</div>
<input type="submit" value="Submit" name="send">
</form>
</body>
</html>