'my login.php says I have an incorrect password, when it is correct ONLY ON GODADDY
When I try to login in my localhost with XAMPP, there is no error, the log in is successful BUT when I try to log in on the internet (with godaddy) here, it redirects me to the error I created called "http://cosmoonlamps.com/ecom/public/login.php?error=wrongpass" in the header. Please help I am a beginner at this stuff so any help would be much appreciated.
<?php
session_start();
if(isset($_POST['submit'])){
require 'database.php';
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) || empty($password)) {
header("Location: login.php?error=emptyfields");
exit();
}else {
$sql = "SELECT * FROM users WHERE username = ?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: login.php?error=sqlerror");
exit();
} else {
mysqli_stmt_bind_param($stmt, "s", $username);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)) {
$passCheck = password_verify($password, $row['password']);
if ($passCheck == false) {
header("Location: login.php?error=wrongpass");
exit();
} elseif ($passCheck == true) {
session_start();
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $row['username'];
header("Location: ../../successful.php?success=loggedin");
exit();
} else {
header("Location: ../index.php?error=wrongpass");
exit();
}
}else {
header("Location: login.php?error=nouser");
exit();
}
}
}
}else{
header("Location: login.php?error=accessforbidden");
exit();}
?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
