Jump to content

Login Code issues (mysql_fetch_assoc)


Foser

Recommended Posts

R u want to match the password in the row against username.

I did not see any query for that.

Ok try this may be it will work.

 

SELECT * FROM user_info WHERE username = '$user' and password='$pw'

If this doesnot work than try this.

 

$pw =$_POST['pw'];
SELECT * FROM user_info WHERE username = '$user' and  md5(sha1(md5(md5('password')='$pw'

 

Link to comment
Share on other sites

<?php
require("config.php");

$user = mysql_real_escape_string($_POST['user']);
$pw = $_POST['pw'];

mysql_fetch_assoc(mysql_query("SELECT * FROM user_info WHERE username = '$user' and md5(sha1(md5(md5(password)))) = '$pw'")) or die(mysql_error());

if ($pw == $user_info['password'] && $user == $user_info['username']){
mysql_fetch_assoc(mysql_query("SELECT rights FROM user_info WHERE username = '$user'")); 
echo "You are now logged in as a $user_info[rights]."; }
else {
echo "You have typed in an incorrect password or/and username. Please try again."; }

?>

 

This is my edited code

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.