Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $servername = "localhost";
- $dbusername = "root";
- $dbpassword = "";
- $dbname = "d4n13ls";
- $conn = mysqli_connect($servername, $dbusername, $dbpassword, $dbname);
- if(!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- if($_SERVER["REQUEST_METHOD"] == "POST"){
- if(isset($_POST["username"])) {
- $username = stripslashes($_POST["username"]);
- $username = mysqli_real_escape_string($conn, $username);
- $password = stripslashes($_POST["password"]);
- $password = mysqli_real_escape_string($conn, $password);
- $hash = password_hash($password, PASSWORD_DEFAULT);
- $query = "SELECT * FROM members WHERE username=$username AND password=".password_verify($password, $hash);
- if($result = mysqli_query($conn, $query)) {
- $rows = mysqli_num_rows($result);
- if($rows > 1) {
- $_SESSION["username"] = $username;
- header("location: home.php");
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement