我要放的代码如下
<?
if($username!="")
{
mysql_connect("localhost", "root", "");
mysql_select_db("mydata") or die ("不能连接到数据库!");
//判断用户名和密码是否在正确
$strSql="select * from maildata where yhm='$username' and password='$password'";
$result=mysql_query($strSql);// or die("读取数据库出现错误!");
$num=mysql_numrows($result);
mysql_close($myconn);
if($num>0)
{
session_register("user");
session_register("passwd");
$user=$userid;
$passwd=$password;
Header("Location:/test/index.htm");
}
else echo "<center><font color=red>错误!请检查用户名和密码!</font></center><br>";
}
else
{
echo "<center>请输入用户名和密码登录!</center>"
?>
为什么会出错呢?页面要么打不开,要么就是在页面上出现这下代码,为什么?
<?
if($username!="")
{
mysql_connect("localhost", "root", "");
mysql_select_db("mydata") or die ("不能连接到数据库!");
//判断用户名和密码是否在正确
$strSql="select * from maildata where yhm='$username' and password='$password'";
$result=mysql_query($strSql);// or die("读取数据库出现错误!");
$num=mysql_numrows($result);
mysql_close($myconn);
if($num>0)
{
session_register("user");
session_register("passwd");
$user=$userid;
$passwd=$password;
Header("Location:/test/index.htm");
}
else echo "<center><font color=red>错误!请检查用户名和密码!</font></center><br>";
}
else
{
echo "<center>请输入用户名和密码登录!</center>"
?>
为什么会出错呢?页面要么打不开,要么就是在页面上出现这下代码,为什么?
$username=$_POST["username"];
$password=$_POST["password"];
然后再去判断
$password=$_POST["password"];
这两个的值,有没有传过去???
我是菜鸟
还望多多指教
<?php
$username = $_POST["username"];
$password = $_POST["password"];
if($username!="")
{
mysql_connect("localhost", "root", "");
mysql_select_db("mydata") or die ("不能连接到数据库!");
//判断用户名和密码是否在正确
$strSql="select * from maildata where yhm='$username' and mm='$password'";
$result=mysql_query($strSql);// or die("读取数据库出现错误!");
$num=mysql_numrows($result);
mysql_close($myconn);
if($num>0)
{
Header("Location:/test/index.htm");
}
else echo "<center><font color=red>错误!请检查用户名和密码!</font></center><br>";
}
else
{
echo "<center>请输入用户名和密码登录!</center>"
?>
<TABLE align=center border=0 cellPadding=5 cellSpacing=1
class=tablebodycolor width=312>
<TBODY>
<TR>
<TD class=tdheadcolor width=312>@客户登陆</TD></TR>
<TR>
<TD class=tdbodycolor width=312>
<DIV align=center>用户名:
<INPUT class=input maxLength=20
name=username size="20"> *</DIV></TD></TR>
<TR>
<TD class=tdbodycolor width=312>
<DIV align=center>密 码:
<INPUT class=input maxLength=32 name=password
type=password size="20"> *</DIV></TD></TR></TBODY></TABLE>
<DIV align=center><INPUT class=button name=Submit type=submit value=登录>
</DIV></FORM></DIV></TD></TR></TBODY></TABLE><FORM action="<?echo $PHP_SELF?>" method=post >这一句有点问题吧
如果把PHP放在另一个页面,你应该设好action的值。
我把action也设好了,是<FORM action="post.php" method=post >
另一个页面也就是post.php了
可是还是不成功
为什么呀
$num=mysql_numrows($result);
mysql_close($myconn);
$num=mysql_numrows($result);此行代码错误!!!
$num=mysql_num_rows($result)