I hosted my website on a localserver using xampp. So I was trying to access the website from another computer which was on the same network. I could access the index.html file that had to enter login details like the username and password but when I hit submit, I don't get to php page which should show the details of the user by retrieving it from the database. How am I suppose to access the php file too? I was able to access the phpmyadmin page too from the other computer but can't access the php page as it says "the site can't be reached. localhost refused to connect"
My html code
<!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>
My php code
<?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";
}
?>