我创建了一个登录表单,该表单应该在发送表单后将用户引导到页面,但它只显示一个空白页面
链接为** http://localhost/Cisu/AccHolder/holderlogin.php
登录表单
<?php
session_start();
?>
<!DOCTYPE html>
<html >
<head>
<title>Login</title>
<link type="text/css" rel="stylesheet" href="css/login.css">
</head>
<body>
<form method="" action="holderlogin.php">
<div class="container">
<div class="profile">
<button class="profile__avatar" id="toggleProfile">
<img src="images/sbma.png" alt="Avatar" />
</button>
<div class="profile__form">
<div class="profile__fields">
<div class="field">
<input type="text" id="user" name="user" class="input" required pattern=.*\S.* />
<label for="username" class="label">Username</label>
</div>
<div class="field">
<input type="password" id="pass" name="pass" class="input" required pattern=.*\S.* />
<label for="password" class="label">Password</label>
</div>
<div class="profile__footer">
<input id="Submit" name="Submit "type = "Submit" class="btn"/>
</div>
</div>
</div>
</div>
</div>
<script src="javascript/login.js"></script>
</form>
</body>
</html>
holderlogin.php
<?php
ob_start();
session_start();
include('dbconn.php');// Database connection and settings
// checking the user
if(isset($_POST['Submit'])){
$user = mysqli_real_escape_string($con,$_POST['user']);
$pass = mysqli_real_escape_string($con,$_POST['pass']);
$sel_user = "select * from tbl_accholder where accholder_Username='$user' AND accholder_Password='$pass'";
$run_user = mysqli_query($con, $sel_user);
$check_user = mysqli_num_rows($run_user);
if($check_user==1){
while ($row = mysqli_fetch_array($run_user)) {
$run_ID = $row['accholder_ID'];
$run_user = $row['accholder_Username'];
}
$_SESSION['accholder_Username']= $user;
$_SESSION['accholder_ID']= $run_ID;
header( 'Location: MainMenu.php');
} else
echo "please wait while redirecting...";
echo "<script> alert('Log-In Failed!'); </script>";
echo "<script> document.location.href = 'Login.php' </script>";
ob_end_flush();
}
?>
答案 0 :(得分:0)
不知道它是否会导致你的问题,但你在php声明之前有一个领先的空间 - 如果你在代码中稍后设置标题请求,这可能会导致php渲染出现问题 - 不能渲染任何字符在标头请求之前。
<?php
您还将表单的操作列为“holderlogin.php”
但是将文件名称列为“Holderlogin.php” - 这在输入代码时可能只是一个错字,但值得检查。
答案 1 :(得分:0)
另外 - 您没有为表单列出任何方法,但是正在检查$ _POST数组以检查“提交”。它应该是:
<form method="POST" action="holderlogin.php">
答案 2 :(得分:0)
您正在检查是否已设置requests
。
但是,在您的表单中,$_POST['Submit']
属性为name
,并且有额外的空格:
Submit
这可能是问题的原因,因为你说给我显示了一个空白页。