当我提交表单时,页面只是重新加载。即使我更改PHP文件的操作结果是相同的。没有输出告诉我代码运行的状态。我共享的PHP是login.php
<?php
include 'connect.php';
if(isset($_POST['submit']))
{
$n=$_POST['name'];
$p=$_POST['pass'];
$q="SELECT NAME FROM user
WHERE name='$n' and password='$p';";
$res=$conn->query($q);
echo "k";
echo "<script>window.alert('here')</script>";
if($res->num_rows == 1)
{
session_start();
$_SESSION['name']=$n;
$_SESSION['pass']=$p;
echo "<a href='cust.php'>";
}
else
{
echo "<script>document.getElementById('resp').innerHTML='<i>please enter valid name and password</i><br></script>'";
}
}
?>
<html>
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="index,follow" />
<!--<link rel="stylesheet" type="text/css" href="styles.css" />-->
</head>
<body>
<form method="post" action="login.php" enctype="application/x-www-form-urlencoded">
<!--<b>First Day of stay</b><input type="date" name="start"><br><br>
<b>Last Day of stay</b><input type="date" name="start"><br><br>-->
<input type="text" id="name" placeholder="Your name"><br><br>
<input type="password" id="pass" placeholder="password"><br><br>
<input type="submit" text="login">
<span id="resp">
</span>
</form>
</body>
</html>
答案 0 :(得分:0)
稍作修正:
<input type="text" id="name" name="name" placeholder="Your name"><br><br>
<input type="password" id="pass" name="pass" placeholder="password"><br><br>
<input type="submit" name="submit" text="login">