我使用xampp在本地服务器上托管了我的网站。所以我试图从同一网络上的另一台计算机访问该网站。我可以访问必须输入用户名和密码等登录详细信息的index.html文件,但是当我点击提交时,我没有进入php页面,该页面应该通过从数据库中检索来显示用户的详细信息。我怎么想访问php文件呢? 我也可以从另一台计算机上访问phpmyadmin页面,但无法访问php页面,因为它说“#34;网站无法访问”。 localhost拒绝连接"
我的HTML代码
<!DOCTYPE html>
<html>
<head>
<title>Login to Student's Database</title>
<style>
label {
font: normal 12px courier !important;
}
.sbm{
padding: 10px;
margin-left: 50px;
}
.whole{
background-image: url("images/bg-01.jpg");
background-attachment: fixed;
width: 1340px;
height: 640px;
background-repeat: repeat-x;
}
p {
font: bold 20px sans-serif;
padding: 20px;
}
</style>
</head>
<body>
<div class="whole">
<div align="center">
<form name="hun" method="post" action="http://localhost/exam/retrieve.php">
<p>Welcome To Student's Record</p>
<label for="user" > Username :</label>
<input type="text" name="username"><br><br>
<label for="pass"> Password :</label>
<input type="password" name="pass"> <br><br>
<div class="sbm"><input type="submit" name="submit"></div>
</form>
<div align="center">
</div>
</body>
</html>
我的PHP代码
<?php
$puser = $_POST['username'];
$ppass = $_POST['pass'];
$con = mysqli_connect('localhost','root','','student');
if(!$con)
{
die("Could not connect".mysql_error());
}
$pss=$ppass;
$usr=$puser;
$flag=0;
$que = "select * from rec";
$q = mysqli_query($con, $que);
if(!$q)
{
echo "Could not retrieve!";
}
else
{
while($ret = mysqli_fetch_array($q, MYSQLI_NUM))
{
if(($pss==$ret[1])&&($usr==$ret[0]))
{ $flag=1;
echo "Welcome to University<br>";
echo "Name = ";
echo $ret[2] . "<br>";
echo "Roll = ";
echo $ret[3]."<br>";
echo "Physics = ";
echo $ret[4]."<br>";
echo "Chemistry = ";
echo $ret[5]."<br>";
echo "Maths = ";
echo $ret[6];
}
}
}
if(!$flag)
{
echo "Wrong username or password";
}
?>