There is a form

<form action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="event" value="signup"/> <div class="form-group"> <label class="control-label" for="input-email"><?=_('Логин')?></label> <input name="uname" value="" placeholder="<?=_('Логин')?>" id="input-email" class="form-control" type="text"> </div> <div class="form-group"> <label class="control-label" for="input-password"><?=_('Пароль')?></label> <input name="pwd" value="" placeholder="<?=_('Пароль')?>" id="input-password" class="form-control" type="password"> </div> <div class="form-group"> <input name="remember" type="checkbox" value="1"/> <?=_('Запомнить')?> </div> 

The form handler is working, but there is a problem that validation does not work and gives the error Notice: Undefined index: err

 <?if($_GET['err']=='1'):?><div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?=_('Вы ввели неправильный логин или пароль')?> </div><?endif?> 
  • if (isset($_GET['err'])) - Suvitruf
  • I tried to do so. The error disappears, but validation still does not work. - Renat Klindzhev February
  • What does it mean does not work? - Suvitruf
  • I enter random symbols into the form, press enter and I just reset everything. - Renat Klindzhev February
  • And what should happen? First of all, your err form is not sent to you, and secondly, your post form sends a request. - Suvitruf

1 answer 1

You need to check first whether there is such an element in $_GET :

 $err = isset($_GET['err']) ? $_GET['err'] : '0; 

Documentation :

The variable is variable; It is a list of variables. It is also a major security risk with register_globals turned on. It is an error. if a variable has been already initialized.