3 Replies - 1436 Views - Last Post: 08 March 2010 - 05:55 AM Rate Topic: -----

#1 mutant x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-November 09

PHP login script

Posted 08 March 2010 - 04:23 AM

Hi guys, i have written a php login script but its not working and i just don't know what is wrong with it. I have attached the script. Please helpAttached File  login-exec.php (1.84K)
Number of downloads: 70

Is This A Good Question/Topic? 0
  • +

Replies To: PHP login script

#2 aniri  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 54
  • View blog
  • Posts: 657
  • Joined: 24-November 09

Re: PHP login script

Posted 08 March 2010 - 05:05 AM

What exactly isn't working with your script?
Was This Post Helpful? 0
  • +
  • -

#3 mutant x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 27-November 09

Re: PHP login script

Posted 08 March 2010 - 05:20 AM

View Postaniri, on 08 March 2010 - 04:05 AM, said:

What exactly isn't working with your script?


Am not really sure but i think there is a problem with the query posted below
//Create query
	$qry="SELECT * FROM users WHERE username='$_POST[username]' AND
         password='".md5($_POST['password'])."'";
        echo $qry;
	$result=mysql_query($qry) or die(mysql_error());
	
	//Check whether the query was successful or not
	if($result) {
		if(mysql_num_rows($result) == 1) {
			//Login Successful
			session_regenerate_id();
			$member = mysql_fetch_assoc($result);
			$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
			$_SESSION['SESS_FIRST_NAME'] = $member['fname'];
			$_SESSION['SESS_LAST_NAME'] = $member['lname'];
			session_write_close();
			header("location: account.php");
			exit();
		}else {
			//Login failed
			header("location: login-failed.php");
			exit();
		}
	}else {
                //die('Query failed');
		die(mysql_error());
	}

This post has been edited by JackOfAllTrades: 08 March 2010 - 05:53 AM
Reason for edit:: Added code tags. PLEASE!!! [code]...PUT YOUR CODE IN HERE...[/code]

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6106
  • View blog
  • Posts: 23,653
  • Joined: 23-August 08

Re: PHP login script

Posted 08 March 2010 - 05:55 AM

How to Ask Questions the Smart Way
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1