注册登录页面
<form id="form1" name="form1" method="post" action="checklogin.php">
<p>
<label>name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>password
<input type="password" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="post" id="post" value="Submit" />
</label>
<a href='zhuce.php'>注册</a>
</p>
</form>
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<form id="form1" name="form1" method="post" action="checklogin.php">
<p>
<label>name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>password
<input type="password" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="post" id="post" value="Submit" />
</label>
<a href='zhuce.php'>注册</a>
</p>
</form>
<?php
$username=$_POST[name];
$password=$_POST[password];
if($_POST['name'] == "")
{
echo "请填写用户名<br><a href='login.php'>返回</a>";
}elseif($_POST['password'] == "")
{
echo "请填写密码<br><a href='login.php'>返回</a>";
}
else
{
$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');
$query = "select * from admin where username='$username' and password='$password'";
$result = mysql_query($query);
$row=mysql_num_rows($result);
if($row>0)
{
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"登陆成功\");\r\n";
echo " location.replace(\"success.php\");\r\n"; // 自己修改网址
echo "</script>";
exit;
}
else
{echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"您输入的密码不正确!请重新输入!\");\r\n";
echo " history.back();\r\n";
echo "</script>";
exit;
}
}
?>
<?php
echo "恭喜你登陆成功!"
?>
<form id="form1" name="form1" method="post" action="yanzhen.php">
<p>
<label>new name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>new password
<input type="password" name="password" id="password" />
</label>
</p>
<p>
<label>new password again
<input type="password" name="newpassword" id="newpassword" />
</label>
</p>
<label>
<input type="submit" name="post" id="post" value="register" />
</label>
<a href='login.php'>返回</a>
</p>
</form>
<?php
$username=($_POST['name']);
$password=($_POST['password']);
$newpassword=($_POST['newpassword']);
$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');
if($username=="")
{
echo "<a href=zhuce.php>用户名不能为空</a>";
return;
}
if($password==$newpassword)
{$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');
$query="insert into admin (username,password) values ('$username','$password');";
mysql_query($query);
mysql_query("commit");
echo "<a href=login.php>注册成功</a>";
}
else
{echo "<a href=zhuce.php>密码不一致</a>";}
?>
<p>
<label>name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>password
<input type="password" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="post" id="post" value="Submit" />
</label>
<a href='zhuce.php'>注册</a>
</p>
</form>
<?php
$username=$_POST[name];
$password=$_POST[password];
if($_POST['name'] == "")
{
echo "请填写用户名<br><a href='login.php'>返回</a>";
}elseif($_POST['password'] == "")
{
echo "请填写密码<br><a href='login.php'>返回</a>";
}
else
{
$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');
$query = "select * from admin where username='$username' and password='$password'";
$result = mysql_query($query);
$row=mysql_num_rows($result);
if($row>0)
{
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"登陆成功\");\r\n";
echo " location.replace(\"success.php\");\r\n"; // 自己修改网址
echo "</script>";
exit;
}
else
{echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"您输入的密码不正确!请重新输入!\");\r\n";
echo " history.back();\r\n";
echo "</script>";
exit;
}
}
?>
<?php
echo "恭喜你登陆成功!"
?>
<form id="form1" name="form1" method="post" action="yanzhen.php">
<p>
<label>new name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>new password
<input type="password" name="password" id="password" />
</label>
</p>
<p>
<label>new password again
<input type="password" name="newpassword" id="newpassword" />
</label>
</p>
<label>
<input type="submit" name="post" id="post" value="register" />
</label>
<a href='login.php'>返回</a>
</p>
</form>
<?php
$username=($_POST['name']);
$password=($_POST['password']);
$newpassword=($_POST['newpassword']);
$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');
if($username=="")
{
echo "<a href=zhuce.php>用户名不能为空</a>";
return;
}
if($password==$newpassword)
{$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');
$query="insert into admin (username,password) values ('$username','$password');";
mysql_query($query);
mysql_query("commit");
echo "<a href=login.php>注册成功</a>";
}
else
{echo "<a href=zhuce.php>密码不一致</a>";}
?>