Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8508935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:17:49+00:00 2026-06-11T03:17:49+00:00

Hope some one can help me out here, i created a system with more

  • 0

Hope some one can help me out here,
i created a system with more than 1 user, each user have a unique username and id.
My problem now is how can i set my system in such a way that when a user log in, the system will direct the user to view a particular row in the database based on their username or id.

My Code to Access the Database is:

<?php


$con = mysql_connect("localhost","root","");
mysql_select_db("uloaku", $con);
$count = 1;
$y = mysql_query("SELECT * FROM transaction WHERE username = '".$_SESSION['username']."' LIMIT 1");
if(mysql_num_rows($y) != 0){

echo "<table border=\"1\" width=\"800\" >";
echo "<tr id=\"bold\">
<td>No</td>
<td align=\"center\" width=\"120\">Account Owner</td>
<td align=\"center\" width=\"120\">Deposit Date</td>
<td align=\"center\" id=\"bold\" width=\"150\">Current Balance</td>
<td align=\"center\" width=\"150\">Available Balance</td>
<td align=\"center\">Account Status</td>
</tr>";

while ($z = mysql_fetch_array($y, MYSQL_BOTH)){
        echo "<tr>
        <td>".$count++."</td>
        <td id=\"color\" align=\"center\">".$z[1]."</td>
        <td id=\"color\" align=\"center\">".$z[2]."</td>
        <td id=\"color\" align=\"center\">".$z[3]."</td>
        <td id=\"color\" align=\"center\">".$z[4]."</td>
        <td id=\"color3\" align=\"left\">".$z[5]."</td>
        </tr>";
    }
    echo "</table>";
    }
?>

My Login Page Looks Like This:

<?php

session_start();

$_SESSION['username'] = $username;

$username = $_POST['username'];

$password = $_POST['password'];

if ($username&&$password)

{
$connect = mysql_connect("localhost","root","") or die("cannot connect!");
mysql_select_db("uloaku") or die("cannot find data base!");
$query = mysql_query ("SELECT * FROM keyaku WHERE    username='".mysql_real_escape_string($username)."' AND     password='".mysql_real_escape_string($password)."'");
$numrows = mysql_num_rows($query);

if ($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
    $dbusername = $row['username'];
    $dbpassword = $row['password'];
}
if ($username==$dbusername&&$password=$dbpassword)
{
    echo "Welcome $username";
}
else
    echo "Invalid Password";
}
else
die("Invalid User");

}

else
 die("Please Enter a UserName and Password.");

?>

So far my log-in is working as i want it, and my database retrieves information the only problems is that it retrieves all information which is in the database but i want it to retrieve information based on the username or id of the person that logs in

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:17:50+00:00Added an answer on June 11, 2026 at 3:17 am

    First of all, I bet this piece of code does not work at all:

    $query = mysql_query ("SELECT * FROM keyaku WHERE        username='$username'&&password='$password'");
    

    … there is no such thing as && in MySQL, therefore the query will return empty result. If you want it to work, do it at least this way (prevents SQL injection, too!):

    $query = mysql_query ("SELECT * FROM keyaku WHERE username='".mysql_real_escape_string($username)."' AND password='".mysql_real_escape_string($password)."'");
    

    Second of all, you need some way to store your login information, so it can be reused later on. If you can use sessions, the simplest way is to store username (or whichever information is linked to the row you need):

    $_SESSION['username'] = $username;
    

    Then, in your first page, update SQL to read as follows (change the column ID per your needs):

    $y = mysql_query("SELECT * FROM transaction WHERE username = '".$_SESSION['username']."' LIMIT 1");
    

    … you don’t even need the LIMIT 1 part if your username field in transaction table is indexed as a primary/unique key.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope some one can help me out here, i guess am not calling my
I hope there is someone who can help me out here. I have found
I have a small problem here and hope that someone can help me out.
Here's a strange one. I hope you can help. I'm trying to setup and
Hope someone can help me out with this problem I am having. I just
I'm almost losing it, i really hope someone can help me out! I'm using
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
I hope someone can help me here. I'm having trouble loading this variable. Right
I hope someone can help here, we're having an incredibly annoying time with Visual
I hope someone can help with the following. I'm trying to create a user-specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.