我的登录表单不显示。我得到一个空白页。
所以请发布正确的代码,以便我可以轻松替换它。我是 php 新手,所以我的代码不会像你的那样超级专业。
这是我的代码:
<?php
session_start();
?>
<head>
<meta http-equiv=""Content-Type" content="text/html"; charset=utf-8 />
<title>Member Register</title>
</head>
<body><?php
$form = "<form action='./login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login' /></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']) {
$user = $_POST['user'];
$password = $_POST['password'];
if ($user) {
if ($password) {
require("connect.php");
$password = md5(md5("Ji5t63s".password."v5h2ih47");
$query = mysql_query("SELECT * FROM users WHERE username='$user'");
$numrows = mysql_num_rows($query);
if ($numrows == 1) {
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
if ($password == $dbpass){
if ($dbactive == 1){
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "You have been logged in as <b>$dbuser</b>. <a href="./member.php">Click here</a> to go to the member page.";
}
else
echo "you must activate your account to login. $form";
}
else
echo "you did not entered a correct password. $form";
}
else
echo "The user you entered was not found. $form";
mysql_close();
}
else
echo "You must enter you password. $form";
}
else
echo "You must enter your username. $form";
}
else
echo $form;
?>
</body>
</html>