/*
Included files
*/
/*
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 ();//Instantiate class MySQL
$result = $db->query_exec ($query _user);//Verify User
$num _results= $result->num_rows;//get the record rows in the database
if ($num _results==0)
{
Echo ' Login fail!! ';
?>
<p><a href= "./template/login.htm" > Back to login </a></p>
<?php
}else{
Header ("Location:./index.php");
}
?>
/*
Templates/login.tpl
*/
<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>
<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= "align=" "right" > User name:</td>
<td><input name= "name" type= "text" onmouseover= "this.style.backgroundcolor= ' #ffffff '" onmouseout= " This.style.backgroundcolor= ' #e8f4ff ' "size="/></td>
</tr>
<tr>
<TD height= "align=" "right" > Password:</td>
<td><input name= "password" type= "password" id= "password" onmouseover= "this.style.backgroundcolor=" #ffffff ' "onmouseout=" this.style.backgroundcolor= ' #e8f4ff ' "size="/></td>
</tr>
<tr>
<TD height= "" "align=" right "> Verification Code:</td>
<td><input name= "Check" type= "text" id= "check" onmouseover= "this.style.backgroundcolor= ' #ffffff '" onmouseout= "this.style.backgroundcolor= ' #e8f4ff '" size= "/></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 "Connection database failed!";
Exit
}
return $db;
}
}
?>
/*
Effect is */
Category: PHP
Full code for PHP landing page