I have been working on an administration login page using php and mysqli. When I try and use my localhost I get this error: Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404 localhost Apache/2.4.29 (Win32) OpenSSL/1.1.0g PHP/7.2.0
I checked the path and nothing is wrong, so I can't figure out why it will not show up.
Her is my login info:
localhost:10080/pinkys_pearls/storeadmin/admin_login.php
Everything is in the htdocs folder (using Xampp) and still can't figure thisout. Here is the code I am using:
<?php
session_start();
if(isset($_POST['submit'])) {
include "../storescripts/connect_to_mysql.php";
$con = mysqli_connect("$db_host","$db_username","$db_pass","$db_name");
$username = mysqli_real_escape_string($con, $_POST['username']);
$password = mysqli_real_escape_string($con, $_POST['password']);
//Error handler
//Check for empty fields
if (empty($username) || empty($password)) {
header("Location: ../admin_login.php?admin_login=empty");
exit();
} else {
//Check if charactors are valid
if (!preg_match("/^[a-zA-Z0-9]*$/", $username) || !preg_match("/^[a-zA-Z0-9]*$/", $password)) {
header("Location: ../admin_login.php?admin_login=invalid");
exit();
} else {
$sql = "SELECT * FROM admin WHERE username = '$username'' AND password = '$password'";
$result = mysqli_query($con, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck < 1) {
header("Location: ../admin_login.php?admin_login=invalid");
exit();
} else {
if ($row = mysqli_fetch_assoc($result)) {
$_SESSION['manager'] = $row['username'];
$_SESSION['manager_pwd'] = $row['password'];
header("Location: admin_index.php"); //relocate to index
page
exit();
} else{
echo 'username and password invalid. Please try again';
}
}
}
}
} else{
header("Location: ../admin_login.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Log In </title>
<link rel="stylesheet" href="../style.css" type="text/css" media="screen" />
</head>
<body>
<div align="center" id="mainWrapper">
<div id="pageContent"><br />
<div align="left" style="margin-left:24px;">
<h2>Please Log In To Manage the Store</h2>
<form id="form1" name="form1" method="POST" action="admin_login.php">
User Name:<br />
<input name="username" type="text" id="username" size="40" />
<br /><br />
Password:<br />
<input name="password" type="password" id="password" size="40" />
<br />
<br />
<br />
<input type="submit" name="button" id="button" value="Log In" />
</form>
<p> </p>
</div>
<br />
<br />
<br />
</div>
</div>
</body>
</html>
I have been over this a hundred times looking for the solution. Can someone tell me how to correct the problem?
Thanks.