PHP登陸頁面完整代碼

來源:互聯網
上載者:User

標籤:style   blog   http   ar   io   color   os   sp   for   

/*

包括的檔案

*/

/*

login.php

*/

 

<?php
require(‘./mysql.php‘);
$username=$_REQUEST[‘username‘];
$passwd=$_REQUEST[‘passwd‘]
session_start();
$_SESSION[‘s_username‘]=$username;
$query_user="select * from user where username = ‘$username‘ and passwd = ‘$passwd‘";
$db=new mysql();//執行個體化類mysql
$result = $db->query_exec($query_user);//驗證使用者
$num_results=$result->num_rows;//取得資料庫中的記錄行

if($num_results==0)
{
    echo ‘login fail!!‘;
?>
<p><a href="./template/login.htm">返回登陸</a></p>
<?php
}else{
header("Location: ./index.php");
}
?>

/*

templates/login.tpl

*/

<html>
<head>
<meta http-equiv="text/html;charset=‘utf-8‘">
<link  rel="stylesheet" type="text/css" href="./css/login.css">
<script type="text/javascript" src="js/face.js"></script>
</head>
<body>
<table width="400px" height="208" border="0" cellpadding="0" cellspacing="0" >
<form id="login" name="login" method="post" action="a.php" onSubmit="">
  <tr>
    <td height="25"  align="right">使用者名稱:</td>
    <td><input name="name" type="text" onmouseover="this.style.backgroundColor=‘#ffffff‘" onMouseOut="this.style.backgroundColor=‘#e8f4ff‘" size="15" /></td>
  </tr>
  <tr>
    <td height="25" align="right">密碼:</td>
    <td><input name="password" type="password" id="password"  onmouseover="this.style.backgroundColor=‘#ffffff‘" onMouseOut="this.style.backgroundColor=‘#e8f4ff‘" size="15" /></td>
  </tr>
  <tr>
    <td height="25"align="right">驗證碼:</td>
    <td><input name="check" type="text" id="check"  onmouseover="this.style.backgroundColor=‘#ffffff‘" onMouseOut="this.style.backgroundColor=‘#e8f4ff‘" size="10" /><img src="code.php" id="code" /></td>
  </tr>

/*

mysql.php

*/

<?php
    var $db_host    = ‘localhost‘;
    var $db_username= ‘root‘;
    var $db_password= ‘123‘;
    var $db_database= ‘new‘;

   
        $db =mysql_connect($ db_host,$db_username,$-> db_password,$-> db_database);
        if (mysqli_connect_errno()) {
            echo "串連資料庫失敗!";
            exit;
        }
        return $db;
    }
    
}
?>

/*

效果為*/

 分類: PHP

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.