21,887
社区成员
发帖
与我相关
我的任务
分享
<?php
if($_POST["register"]) header('location:application.html');
else{
$conn=mysql_connect("127.0.01","root","");
if(mysql_select_db("MYDB"))
{
echo "open sucessfully!";
if($_POST["username"]&&$_POST["password"]&&$_POST["login"])
{
echo "post sucessfully!";
$sql="SELECT ID FROM USER WHERE EXISTS (
SELECT * FROM user WHERE USER=$username and PSW=$password)";
$result=mysql_query($sql);
if($result)
{
echo "欢迎你!正在跳转,请稍候...";
header('location:http://xyh.jnu.edu.cn/');
}
else echo "用户名无效或密码错误,请重新输入!";
}
else echo "请将信息填写完整!";
}
else echo "数据库连接出错";}
<html>
<body>
<form name="login" action="?" method="post" target="_self">
<input name="text" type="text" size="20" style="margin-bottom:40px;"/>
<input name="password" type="password" size="20" />
<input id="button" type="submit" value="" name="register" style="background-image:url(images/apply.jpg);" onclick="location.href='application.html'">
<input id="button" type="submit" value="" name="login" style="background-image:url(images/login.jpg);;">
</form>
</body>
</html>
——login.php——
<?php
$conn=mysql_connect("localhost:3306","root","root");
if(mysql_select_db("MYDB"))
{
echo "open sucessfully!";
if($_POST["username"] And $_POST["password"])
{
echo "post sucessfully!";
$sql="SELECT ID FROM USER WHERE EXISTS (
SELECT * FROM user WHERE ID=$username and PSW=$password)";
$result=mysql_query($sql);
if($result)
{
echo "欢迎你!正在跳转,请稍候...";
header('location:http://xyh.jnu.edu.cn/');
}
else echo "用户名无效或密码错误,请重新输入!";
}
else echo "请将信息填写完整!";
}
else echo "数据库连接出错";
?>