Jump to content

Retrieving Database Info Based On User logged in


saran.tvmalai

Recommended Posts

I have two tables.

 

Table Name:Users

 

Fields:

 

User_name

user_email

user_level

pwd

 

 

2.Reference

 

Fields:

 

refid

username

origin

destination

 

user_name in the users table and the username field in reference fields are common fields.

 

 

 

There is user order form.whenever an user places an order, refid field in reference table will be updated.So the user will be

provided with an refid

 

Steps:

 

1.User needs to log in with a valid user id and pwd

2.Once logged in, there will be search, where the user will input the refid which has been provided to him during the time of order placement.

3.Now User is able to view all the details for any refid

3.Up to this we have completed.

 

Query:

 

Now we need to retrieve the details based on the user logged in.

 

For eg: user 'USER A' has been provided with the referenceid '1234' during the time of order placement

user 'USER B' has been provided with the referenceid '2468' during the time of order placement

 

When the userA login and enter the refid as '2468' he should not get any details.He should get details only for the reference ids which is assigned to him.

Link to comment
Share on other sites

Simply check USERS name against the name of the User in your reference database place it in the results of submitting the refid.

 

Something as simple as

 

if ($YOURUSERARRAY['User_name'] !== $YOURREFARRAY['username'])
{
  echo "Your account holds no records of this reference number !" ;
  echo "<br><a href='refidsearch.php'>Re-enter your reference number</a>";
  exit;
}

 

 

I believe that'd do the trick.

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.