View difference between Paste ID: 3Uxj8S7p and 55vGXepR
SHOW: | | - or go back to the newest paste.
1
<?php
2
session_start();
3
include("config.php");
4
$errorlogin = "Field is Empty";
5
if(isset($_POST['submit']))
6
{
7
$user = $_POST['username'];
8
$pass = $_POST['password'];
9-
if($user == "" || $pass == "")
9+
10
if($user != "" && $pass != "")
11
{
12
	$result = mysql_query("select * from register where BINARY username='$user' and BINARY password='$pass'",$con)
13
or die("Could not execute the select query.");
14
$row = mysql_fetch_assoc($result);
15
if(is_array($row) && !empty($row))
16-
$result = mysql_query("select * from register where BINARY username='$user' and BINARY password='$pass'",$con)
16+
17
$validuser = $row['username'];
18
$_SESSION['valid'] = $validuser;
19
}
20
if(isset($_SESSION['valid']))
21
{
22
echo "Welcome ".$_SESSION['valid']."!";
23
echo "<br/>";
24
echo "<a href='logout.php'>Logout</a>";
25
}
26
else{
27
echo "Wrong Username or Password"; 
28
}
29
}
30
else
31
{
32
$errorlogin;
33
34
}
35
}
36
37
38
?>