0

Please help with these errors in this code.... Errors are

Notice: Undefined index: user in C:\wamp\www\REGDB\login.php on line 13

Notice: Undefined index: password in C:\wamp\www\REGDB\login.php on line 14

Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\REGDB\login.php on line 22

<?php session_start(); ?>
<html>
<head />
<body>
<form action=login.php method=POST>
KeyIDentity: <input type=text name='user'>
Password: <input type=password name='password'>
<input type=submit value='Login'>
</form>

<?php

	$user=$_POST['user'];
	$password=$_POST['password'];
	
		
	if(!isset($_POST['submit'])){
		$con=mysql_connect("localhost", "root", "");
		mysql_select_db("register");
		
		$get=mysql_query("SELECT * FROM users WHERE user='$user' and password='$password'");
		$result=mysql_result($get,0);
		
		mysql_close($con);

		if($result!=0) echo "Login Failed";
		else{
			echo "Login Successful";
			$_SESSION['user']=$user;
		};
	};	
	
?>
</body>
</html>
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by cwarn23
0
<?php session_start(); ?>
<html>
<head />
<body>
<form action=login.php method=POST>
KeyIDentity: <input type=text name='user'>
Password: <input type=password name='password'>
<input type=submit value='Login'>
</form>

<?php

	if(isset($_POST) && !empty($_POST)){
		$con=mysql_connect("localhost", "root", "");
		mysql_select_db("register");
	        $user=mysql_real_escape_string($_POST['user']);
        	$password=mysql_real_escape_string($_POST['password']);		
		$get=mysql_query("SELECT * FROM users WHERE user='$user' and password='$password'");
		$result=mysql_result($get,0);
		
		mysql_close($con);

		if($result!=0) echo "Login Failed";
		else{
			echo "Login Successful";
			$_SESSION['user']=$user;
		}
	}	
	
?>
</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.