首页 > 教學 > php > php登入範例login.php
2012
01-04

php登入範例login.php

<?include("conn.php");?>
<?include("utility.php");?>
<?
session_start();
$Account=$_POST[Account];
$Password=$_POST[Password];
if($Account!="" || $Password!="")
{

	$sSQL="select * from wp_users 
				where user_login='$Account' and user_email ='$Password'";

	$result=mysql_query($sSQL,$conn);

	$rowcount=mysql_num_rows($result);  //計算筆數
	
	//$getrow=mysql_fetch_row($result);  //讀取指標所在的資料
	if($rowcount==0 || $rowcount>1)
	{
		//轉向
		//echo "<META HTTP-EQUIV='refresh' CONTENT='3'>";
		echo "<p align=center><font color=red>帳號密碼錯誤...</font><p>";
		//echo $sSQL;
	}	
	else
	{
		$rows=mysql_fetch_array($result);
		$_SESSION['Admin_sn']=$rows["ID"];
		$_SESSION['RealName']=$rows["user_nicename"];
		echo "登入成功!!";
	}

}
?>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>彰化一整天blog文章列表 </title>
<body>

<center>
<form method="POST" action="login.php" onSubmit="return chkacpw();">
<table border="0" width="700" cellspacing="10">
  <tr>
    <td width="30%" bgcolor="#336699" valign="top">
    <p align="center" style="margin-top: 10; margin-bottom: 0"><b><font size="2" color="#FFFFFF">登錄</font></b></p>

    <table border="1" width="180" cellspacing="0" align=center>
    <tr>
      <td width="36%" align="center" bgcolor="#6699FF">
        <p align="right"><font size="2">帳號:</font></p>
      </td>
      <td width="64%" bgcolor="#6699FF">
        <p align="left"><font size="2"><input type="text" name="Account" size="15" ></font></td>
    </tr>
    <tr>
      <td width="36%" align="center" bgcolor="#6699FF">
        <p align="right"><font size="2">密碼:</font></p>
      </td>
      <td width="64%" bgcolor="#6699FF"><font size="2"><input type="password" name="Password" size="15" ></font></td>
    </tr>
  </table>

    <p align="center"><font size="3"><input type="submit" value="登入" name="OK"><input type="reset" value="清除" name="Cancel"></font></p>

    </td>
  </tr>
</table>
</form>
</center>
<script>
	function chkacpw()
	{
		var account=document.form1.account.value;
		var password=document.form1.password.value;

		errmsg = '';
		
		if ( account == "")
			errmsg += "登入帳號不可為空白\n";
		
		if ( password == "")
			errmsg +="登入密碼不可為空白\n";
		
		if (errmsg != '') {
			alert(errmsg);
			return false;
		} else {	
			return true;
		}
		
	}
	
	function setfocus()
	{
	document.forms[0].Account.focus();
	}
</script>
同步發表於:php登入範例login.php
最后编辑:
作者:明和 蔡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。