0

hii

i am trying to write code for Login but its not working.. i have used this code for my another loginpage there its working dont knw y its not on working on my new page.

when ever i click on Login button it goes in else statement that open sorry page.

heres code i am using..

<?php
if(isset($_REQUEST['Login']))
{
$Username=$_REQUEST['username'];
$Password=$_REQUEST['password'];

$query="SELECT * FROM user";
$result=mysql_query($query);
		while($nt=mysql_fetch_array($result))
		{
		  if(($nt['name']==$Username)&&($nt['password']==$Password))
		  {
		 
		 header("Location:buyticket.php");
		  break;
		  } 
		  else
		 
		 {
		  header("Location: sorry.php");
		  break;
		}
	}
}

i have al the names and variables and matched from my database they are correct.

can anyone tell why it is going in else condition even when i am giving correct username and password

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by iqra123
0

Because the first record inspected in the loop is not the one you're expecting, so it goes to the else.
To verify, delete all users but one (need I mention to take a backup first) and test again.
This is most definately not the best way to accomplish what you're trying to do.

0

problem is solved. i was writing this code outside form tags.
:-D

This question has already been answered. 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.