-
-
Save fellydee/ce49ea46833e523108f350ad3b75d771 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<?php | |
// Database connection parameters. | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$dbname = "SampleDB"; | |
$user=$_POST['uname']; | |
$pass=$_POST['psw']; | |
#echo $user.$pass; | |
$con=mysql_connect('localhost','root','') or die(mysql_error()); | |
mysql_select_db('SampleDB') or die("cannot select DB"); | |
#echo $con; | |
$query=mysql_query("SELECT * FROM sampletable WHERE username='".$user."' AND password='".$pass."'"); | |
$numrows=mysql_num_rows($query); | |
#echo $numrows; | |
if($numrows!=0) | |
{ | |
while($row=mysql_fetch_assoc($query)) | |
{ | |
$dbusername=$row['username']; | |
$dbpassword=$row['password']; | |
} | |
#echo $dbusername.$dbpassword; | |
if($user == $dbusername && $pass == $dbpassword) | |
{ | |
echo "Valid User .. Successfully Logged In !!"; | |
} else { | |
echo "Invalid Username or password!"; | |
} | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment