Created
January 4, 2017 11:32
-
-
Save peerapongsam/23e0439b0978b9eb23540a20005bffa4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
mysql_connect("localhost","root",""); | |
mysql_select_db("tutorials"); | |
$strSQL = "SELECT * FROM member WHERE username = '".mysql_real_escape_string($_POST['txtusername'])."' | |
and password = '".mysql_real_escape_string($_POST['txtpassword'])."'"; | |
$Query = mysql_query($strSQL); | |
$Result = mysql_fetch_array($Query); | |
if(!$Result) | |
{ | |
echo "Username and Password Incorrect!"; | |
} | |
else | |
{ | |
$_SESSION["member_id"] = $Result["member_id"]; | |
$_SESSION["status"] = $Result["status"]; | |
session_write_close(); | |
if($Result["status"] == "admin") | |
{ | |
header("location:admin.php"); | |
} | |
else | |
{ | |
header("location:user.php"); | |
} | |
} | |
mysql_close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment