How to Insert Password Hash PHP in Mysql I XAMPP. - Sub Title English


How to Insert Password Hash  PHP in Mysql  I XAMPP. - Sub Title English 


https://drive.google.com/file/d/1DwHIjw8SL0ICLFbEcik4W41bwHjOayAc/view

HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>FromLogin</title>
<link rel="stylesheet" type="text/css" href="Login.css">
</head>
    <body>
<div class="loginbox">
    <img src="Logo1.png" class="avatar">
    <form method="post" action="insertpassword.php">
    <h1>Login Here</h1>
        <p>Username</p>
        <input type="text" name="username" placeholder="Enter Username"required>
        <p>Password</p>
        <input type="password" name="password" placeholder="Enter Password"required>
        <p>Repassword</p>
        <input type="password" name="repassword" placeholder="Re Password"required>
        <input type="submit" name="save" value="Sign in">
    </form>
</div>
</body>
</html>

PHP

<?php
// Create connection to the database
$conn = mysqli_connect("localhost","root","","loginphp");
//check for database connection error
if(!$conn){
die("Database Error");
}
mysqli_set_charset($conn,"utf8");
$msg="";
if (array_key_exists("username",$_POST) &&
array_key_exists("password",$_POST)&&
array_key_exists("repassword",$_POST)
){
if($_POST["password"]!== $_POST["repassword"])
die("incorrect repassword");
{
echo"Secessfully";
// Insert password
$query = "INSERT INTO loginphp";
$query .= "(username, password)";
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
$query .= "VALUES('{$_POST["username"]}','{$password}')";
if(!mysqli_query($conn,$query)){
echo $query;
echo musqli_error($conn);
}
}
}
?>

Reactions

Post a Comment

0 Comments