大致就这个意思。谢谢了
第1个回答 2009-11-03
<?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>";
}
?>本回答被提问者采纳
第2个回答 2009-11-03
很多这种登陆的例子,百度一下就能找到这种表单提交的代码