mysql - Validation of password and confirm password in PHP Error shows all the time -
so trying create login form , @ part when want validate password , confirm password. code used (you can find below) shows me everytime submit register button "the password , confirm password not match" thought enter same password. idea should changed in code remove error?
<?php session_start(); include('includes/config.php'); include('includes/db.php'); function isunique($email){ $query="select * users email ='$email'"; global $db; $result = $db->query($query); if($result->num_rows>0){ return false; } else return true; } if(isset($_post['register'])) { $_session['name']=$_post ['name']; $_session['email']=$_post ['email']; $_session['password']=$_post ['password']; $_session['confirm_password']=$_post ['confirm_password']; if(strlen($_post['name'])<3){ header("location:register.php?err=".urlencode ("the name must @ least 3 characters long")); exit(); } else if(strlen($_post['password']) < 5 ){ header("location:register.php?err=".urlencode ("the password should @ least 5 characters")); exit(); } else if(strlen($_post['confirm_password']) < 5 ){ header("location:register.php?err=".urlencode ("the confirm password should @ least 5 characters")); exit(); } else if(!isunique($_post['email'])){ header("location:register.php?err=".urlencode ("email in use. please use one")); exit(); } else if($_post['[password'] != $_post['confirm_password']) { header("location:register.php?err=".urlencode ("the password , confirm password not match")); exit(); } } ?>
and here other part put condition when error msg should displayed.
`<form action="register.php" method="post" style="margin-top:35px;"> <h2> register here </h2> <?php if(isset ($_get['err'])) { ?> <div class="alert alert-danger"><?php echo $_get['err']; ?></div> <?php } ?>`
you had little typo:
instead of $_post['[password']
use $_post['password']
Comments
Post a Comment