收到错误:找不到对象错误404 [英] Getting an error: object not found error 404
问题描述
我一直在使用php和mysqli管理登录页面.当我尝试使用本地主机时,出现以下错误: 找不到对象! 在此服务器上找不到请求的URL.如果您手动输入网址,请检查拼写,然后重试.
如果您认为这是服务器错误,请与网站管理员联系.
错误404 本地主机 Apache/2.4.29(Win32)OpenSSL/1.1.0g PHP/7.2.0
我检查了路径,没有错,所以我不知道为什么它不会显示.
她是我的登录信息:
localhost:10080/pinkys_pearls/storeadmin/admin_login.php
所有内容都在htdocs文件夹中(使用Xampp),仍然无法解决.这是我正在使用的代码:
<?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>
我已经搜索了一百次以上了.有人可以告诉我如何解决该问题吗?
谢谢.
您提交的按钮名称为button
<input type="submit" name="button" id="button" value="Log In" />
所以您必须使用button
if(isset($_POST['button'])) {
//code goes here
}
else{
// here....
}
type属性指定要显示的<input>
元素的类型了解详情 .
和name属性指定<input>
元素的名称了解更多.>
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.
You submit button name is button
<input type="submit" name="button" id="button" value="Log In" />
So you have to check condition with button
if(isset($_POST['button'])) {
//code goes here
}
else{
// here....
}
The type attribute specifies the type of <input>
element to display Read more.
and The name attribute specifies the name of an <input>
element Read More.
这篇关于收到错误:找不到对象错误404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!