Jump to content

MySQL and PHP Problem - Selecting a row WHERE username and password match


colleyboy

Recommended Posts

Hello I am having a little problem whilst coding a login system

 

I have done the "login part" but when it gets to the user_cp page I need to display the "user_id" field on the row where the "username" and "password" are a match.

 

 

 

 

 


<?php include "dbconnect.php" ?>

<p>USER CP</p>

<p><A HREF="logout.php">LOGOUT</A></p>

<?php

if (isset($_GET['username'])) {
$username = $_GET['username'];
}

if (isset($_GET['sessionid'])) {
$password = $_GET['sessionid'];

}

?>
<?php

$usersession = mysql_query("SELECT Username, Password FROM boom_users WHERE Username=$username && Password=$password") or 

die(mysql_error());
while($row = mysql_fetch_array($usersession))

{

echo $row['user_id'];

}



echo $username;
echo $password;

?>

 

BTW the username and password are displayed in the URL under "username" and "session_id".  I have echoed these to see if they display on page and they do.  The password is encrypted to not a problem.

 

I think the problem is in the part of:

 

 

"$usersession = mysql_query("SELECT Username, Password FROM boom_users WHERE Username=$username && Password=$password") or 
die(mysql_error()); while($row = mysql_fetch_array($usersession))"

 

It seems to check the table for a column which is the $username and $password from the url and what it should do check the table for where there is a match for username and password and then fetch the data in the column "user_id".

 

Your help is much appreciated and I am sure it is an easy fix as I have been behind the computer around 10 hours today lol :) .

 

Kind Regards,

Ian

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.