Results 1 to 2 of 2

Thread: login and password not working

  1. #1
    Join Date
    Jun 2008
    Posts
    114
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default login and password not working

    hi all i have a login form with user name and password. The user name field is called "user_name" and password field is called "password".
    I have applied the code.
    I m filing the right user and password.
    In the database i have user_id, user_name, password.
    neither an error is coming nor its redirectig it.

    Code:
    require_once("../config.php");
    
    $msg="";
    if(isset($_REQUEST['id']))
    {
    $id=$_REQUEST['id'];
    $qry="select * from admin_table where user_id='$id'";
    $result=mysql_query($qry);
    $row=mysql_fetch_array($result);
    
    
    }
    
    if(isset($_REQUEST['submit']))
    {
    
    	$user_name=$_REQUEST['user_name'];
    	$password=$_REQUEST['password'];
    
    	$qry="select * from admin_table WHERE user_name='$user_name' and password='$password'"; 
    	//echo $qry;
    	
    	$result=mysql_query($qry);
    	
    	if(mysql_num_rows($result)>0)
    	{
    	
    		if(($user_name==$row['user_name']) && ($password==$row['password']))
    		
    		{
    			header("Location: control_panel.php");
    		}
    		else
    		{
    		$msg="Login ID or password is incorrect";
    		}
    	}
    }

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    It's your responsibility to die().

    You can never see error, since you're not instructing the code to show any:
    Code:
    $result=mysql_query($qry) or die(mysql_error());
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •