一个登陆判断的源码
mysql_connect($dbhost,$dbuser,$dbpasswd) or die ("数据库连接失败");
$sql = "SELECT * FROM $ym_article_user_table WHERE username='$username'";
$result = mysql_db_query($dbname, $sql);
$objresult = mysql_fetch_object($result);
$user_password = $objresult->password;
if ($username=="" || $password==""):
echo "用户名或密码不能为空";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=index.php'>";
exit;
endif;if ($user_password == ""):
echo "用户名错误";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=index.php'>";
exit;
endif;if ($password != $user_password):
echo "密码错误";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=index.php'>";
exit;
endif;setcookie ($cookie_name."[1]",$username,time
);echo "登录成功!";
echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=list.php'>";exit;} // end login

解决方案 »

  1.   

    用form表单接受用户输入并传给变量
      

  2.   

    http://www.csdn.net/Develop/read_article.asp?id=13504
      

  3.   

    程序如下:file1.php文件如下<form action="file2.php" method=post>
    <input type="text" name="uid" >
    <input type=submit name="submit">file2.php文件如下<?php 
       if(isset($uid) && $uid)//uid為從表單中傳過來的用戶名。
        {$link=connection();
         $strsql="select * from user where uid='$uid'";
         $result=mysql_query($strsql,$link);
         $row=mysql_fetch_row($result);
         if(!$row[0])
          {$strsql="select * from base_info where uid='$uid'";
           $result=mysql_query($strsql,$link);
           $row=mysql_fetch_row($result);
            if ($row[0])
                {echo "此用戶存在";}
            else
               { echo "此用戶不存在";}
    ?>