伙计们,我对 php 很陌生,我正在尝试制作一个登录页面。
如果声明为真,我如何重定向页面?
我试过 iwth header("location: nextpage.php"); 但它不起作用
<html>
<head>
<title>Uploader</title>
</head>
<body>
<form action="index.php" method="POST" enctype="application/x-www-form-urlencoded">
<input id="login" class="username" type="text" name="username" autofocus placeholder="Username" maxlength="30"/>
<input id="login" class="password" type="password" name="password" placeholder="Password" maxlength="15"/>
<input id="login" class="submit" type="submit" value="Login" />
<p>Last update <span id="lastupdate"><?php echo date('d-m-Y');?></span></p>
<?php
mysql_connect("localhost", "root","******") or die(mysql_error());
mysql_select_db("login") or die(mysql_error());
if(isset($_POST['username']) && isset($_POST['password'])){
$db_user = mysql_query("SELECT username FROM login_tb");
$db_pass = mysql_query("SELECT password FROM login_tb");
$ctrl_user = mysql_result($db_user,0);
$ctrl_pass = mysql_result($db_pass,0);
$username = $_POST['username'];
$password = $_POST['password'];
echo $username . $password;
if(($username || $password) == NULL){
echo "you have entered wrong username or password! <br/> please contact site admin.";
}else{
if($username == $ctrl_user && $password == $ctrl_pass){
header("location: ./nextpage.php");
}
}
}
?>
</body>
</html>
请问有人可以帮助我吗?谢谢