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>
<?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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.