Akhil Vinay Mandava
asked on
how can i add alert message before submitting the page
Before submitting the page i need some alert at the password atleast one special cheracter message . How can i write the code.
<?php
include 'connect.php';
include 'fun.php';
$error = "";
if(isset($_POST['savepass']))
{
$password = $_POST['password'];
$confirmPassword = $_POST['passwordConfirm'];
if(strlen($password) < 5)
{
$error = "Password must be greater than 5 characters";
}
else if($password !== $confirmPassword)
{
$error = "Password does not match";
}
else if (!preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $password))
{
$error = "Atleast one special character in the Password";
}
else
{
/*
$password = password_hash($password,PASSWORD_DEFAULT);
*/
$emp_id = $_SESSION['emp_id'];
if(mysqli_query($con, "UPDATE users SET password='$password' WHERE EmployeeID='$emp_id'"))
{
$error = "Password Changed Successfully, <a href='login2.php'>click here</a> to Log In";
}
}
}
if(logged_in())
{
?>
<?php echo $error; ?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.