10 days Learn PHP Day 7
-
<table width= "100%" height= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "0" > -
<tr> -
<form action= "checklogin.php" method= "post" ><td align= "center" valign= "middle" ><table width= "400" border= "0" cellpadding= "5" cellspacing= "1" class = "tablebg" > -
<tr class = "tdbg" > -
<td colspan= "2" ><div align= "center" >Administrators Login</div></td> -
</tr> -
<tr class = "tdbg" > -
<td><div align= "center" >Username</div></td> -
<td><div align= "center" > -
<input name= "username" type= "text" id= "username" > -
</div></td> -
</tr> -
<tr class = "tdbg" > -
<td><div align= "center" >Password</div></td> -
<td><div align= "center" > -
<input name= "password" type= "password" id= "password" > -
</div></td> -
</tr> -
<tr class = "tdbg" > -
<td colspan= "2" ><div align= "center" > -
<input type= "submit" name= "Submit" value= "Submit" > -
<input type= "reset" name= "Submit2" value= "Clear" > -
</div></td> -
</tr> -
</table></td></form> -
</tr> -
</table>
-
<? -
require_once ( 'conn.php' ); -
session_start(); -
$username = $_POST [ 'username' ]; -
$password = $_POST [ 'password' ]; -
$exec = "select * from admin where username='" . $username . "'" ; -
if ( $result =mysql_query( $exec )) -
{ -
if ( $rs =mysql_fetch_object( $result )) -
{ -
if ( $rs ->password== $password ) -
{ -
$_SESSION [ 'adminname' ]= $username ; -
header( "location:index.php" ); -
} -
else -
{ -
echo "<script>alert('Password Check Error!'); location.href='login.php';<\/ script>" ; -
} -
} -
else -
{ -
echo "<script>alert('Username Check Error!'); location.href='login.php';<\/ script>" ; -
} -
} -
else -
{ -
echo "<script>alert('Database Connection Error!'); location.href='login.php';<\/ script>" ; -
} -
?>
-
<? -
$conn =mysql_connect ( "127.0.0.1" , "" , "" ); -
mysql_select_db( "shop" ); -
?>
-
<? -
session_start(); -
if ( $_SESSION [ 'adminname' ]== '' ) -
{ -
echo "<script>alert('Please Login First'); location.href='login.php';<\/ script>" ; -
} -
?>