php 02

<?php
$conn = mysql_connect("127.0.0.1:3306","root","root");
mysql_select_db("test");
mysql_query("set names gbk");
?>

 

<?php
include 'conn.php';
$exec = "select * from patents  where date='1998' ";
$result=mysql_query($exec,$conn);
while($rs=mysql_fetch_row($result))
{
?>
    <tr>
                  <td bgcolor="#C8F0F1"><a href="<?php echo $rs[3];?>" target="_blank">
    <?php echo $rs[4];?></td>
                  <td width="37%" bgcolor="#C8F0F1"><a href="<?php echo $rs[3];?>"     target="_blank">
                  <?php echo $rs[2];?></a></td>
                </tr>
          
<?php
}
?> 


 <tr height=36>
                <td></td>
                <td>用户名</td>
                <td><input name="username" type="text" id="username"
                  style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"
                  maxlength=15 size=24 value=""></td></tr>

             <form action="checklogin.php" method="post">

 

<?php
require_once('conn.php');
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
$exec = "select * from user where name = '".$username."'";
if($result=mysql_query($exec))
{
  if($rs=mysql_fetch_object($result))
  {
    if($rs->password == $password)
    {
      $_SESSION['adminname']=$username;
   $_SESSION['group'] = $rs->groupname;
   $_SESSION['logintime']=date('m-d H:i:s');
      header("location:adminindex.php");
    }
    else echo "<script>alert('用户名或密码错误!');location.href='login.php';</script>";
  } else echo "<script>alert('用户名或密码错误!');location.href='login.php';</script>";

  } else echo "<script>alert('数据库连接错误,请与管理员联系!');location.href='login.php';</script>";
?>
 

你可能感兴趣的:(PHP)