php登入驗證及代碼實現 含資料庫設計 親測有效

來源:互聯網
上載者:User

標籤:php   密碼   mysql   

深夜調代碼 試過無數種方法終於見了成效

login.php內容如下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>管理員後台登入 </title><!--                       CSS                       --><!-- Reset Stylesheet --><link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" /><!-- Main Stylesheet --><link rel="stylesheet" href="resources/css/style.css" type="text/css" media="screen" /><!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid --><link rel="stylesheet" href="resources/css/invalid.css" type="text/css" media="screen" /><!--                       Javascripts                       --><!-- jQuery --><script type="text/javascript" src="resources/scripts/jquery-1.3.2.min.js"></script><!-- jQuery Configuration --><script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script><!-- Facebox jQuery Plugin --><script type="text/javascript" src="resources/scripts/facebox.js"></script><!-- jQuery WYSIWYG Plugin --><script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script></head><body id="login"><div id="login-wrapper" class="png_bg">  <div id="login-top">    <h1>管理員後台登入</h1>    <!-- Logo (221px width) -->    <a href="#"><img id="logo" src="resources/images/logo.png" alt="Simpla Admin logo" /></a> </div>  <!-- End #logn-top -->  <div id="login-content">    <form action="login_1.php" method = "POST">      <fieldset>      <p>        <label>使用者名稱</label>        <input class="text-input" type="text" name = "loginName"/>      </p>      <div class="clear"></div>      <p>        <label>密碼</label>        <input class="text-input" type="password" name = "loginPwd"/>      </p>      <div class="clear"></div>      <p id="remember-password">        <input type="checkbox" />        記住我 </p>      <div class="clear"></div>      <p>        <input id = "loginbtn" class="button" type="submit" value="登入" name = "submit" />      </p>      </fieldset>    </form>  </div>  <!-- End #login-content --></div><!-- End #login-wrapper --></body></html>


login_1.php內容如下

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><?php error_reporting(0);if(!isset($_POST['submit'])){      exit('非法訪問!');  } $name=$_POST['loginName'];$password=$_POST['loginPwd'];include('connect.php');  if($name && $password){  echo "come in";  $sql="select * from admin where adName='$name' and adPwd='$password' ";  $res=mysql_query($sql);  echo "$res";  echo "$name";  $test=mysql_fetch_array($res);  if($test && strcmp($name,'admin')==0){  header("location:index.php");  echo "finally";  exit;  }else{  echo "fail to login";  exit;  }  mysql_free_result($res);  mysql_close($conn);  }?>


connect.php內容如下

<?php $conn=mysql_connect('localhost','root','') or die("串連失敗".mysql_error());  mysql_select_db('door',$conn) or die("選擇資料庫失敗".mysql_error());  mysql_query("set names gb2312");?>



資料庫設計 如下


php登入驗證及代碼實現 含資料庫設計 親測有效

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.