2个回答
展开全部
<?php
session_start();
$coon_ = "localhost";
$name_ = "root";
$password_="root";
$error_ = "无法连接数据库1,请重来";
$conn=mysql_connect($coon_,$name_,$password_) or die($error_);
mysql_select_db("abc")
or die($error_);
mysql_query("SET NAMES 'gbk'");//解决汉字
$row = mysql_fetch_assoc(mysql_query(" SELECT pass,qx,sex FROM users where name = '$username' and pass = '$pass'"));
$dl_mima=$row[pass];$dl_qx=$row[qx];$dl_sex=$row[sex];
if($dl_mima=="")
{
echo "<script>alert(\"您输入的用户名或者密码错误,请重新输入!\")</script>";
echo "<form id=\"form2\" name=\"form2\" method=\"post\" action=\"\">
<table width=\"452\" height=\"148\" border=\"1\" align=\"center\">
<tr>
<td><p>
<font color=red>用户名:</font>
<input name=\"username\" type=\"text\" id=\"username\" />
</p>
<p>
<font color=red>密 码:</font>
<input name=\"pass\" type=\"password\" id=\"pass\" />
</p>
<p>
<input type=\"submit\" name=\"Submit\" value=\"提交\" />
</p></td>
</tr>
</table>
</form>
";
}
else
{
$_SESSION['yhm']=$username;
$_SESSION['qx']=$dl_qx;
$_SESSION['sex']=$dl_sex;
echo "<script>alert('成功登陆')</script>";
echo "<script>window.location.href='index.php';</script>";
}
?>
session_start();
$coon_ = "localhost";
$name_ = "root";
$password_="root";
$error_ = "无法连接数据库1,请重来";
$conn=mysql_connect($coon_,$name_,$password_) or die($error_);
mysql_select_db("abc")
or die($error_);
mysql_query("SET NAMES 'gbk'");//解决汉字
$row = mysql_fetch_assoc(mysql_query(" SELECT pass,qx,sex FROM users where name = '$username' and pass = '$pass'"));
$dl_mima=$row[pass];$dl_qx=$row[qx];$dl_sex=$row[sex];
if($dl_mima=="")
{
echo "<script>alert(\"您输入的用户名或者密码错误,请重新输入!\")</script>";
echo "<form id=\"form2\" name=\"form2\" method=\"post\" action=\"\">
<table width=\"452\" height=\"148\" border=\"1\" align=\"center\">
<tr>
<td><p>
<font color=red>用户名:</font>
<input name=\"username\" type=\"text\" id=\"username\" />
</p>
<p>
<font color=red>密 码:</font>
<input name=\"pass\" type=\"password\" id=\"pass\" />
</p>
<p>
<input type=\"submit\" name=\"Submit\" value=\"提交\" />
</p></td>
</tr>
</table>
</form>
";
}
else
{
$_SESSION['yhm']=$username;
$_SESSION['qx']=$dl_qx;
$_SESSION['sex']=$dl_sex;
echo "<script>alert('成功登陆')</script>";
echo "<script>window.location.href='index.php';</script>";
}
?>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
很多这种登陆的例子,百度一下就能找到这种表单提交的代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询