Jump to content
xisto Community
Sign in to follow this  
sparkx

Help Looking Up Users. I need some help with looking up users.

Recommended Posts

OK so can anyone show me a file that will connect to an sql server with an user inputed quary? So here is an example of what I want to do:You go to a page to find information about James, you would type in example.php?user=James and the page would find all the data about James (all the tables), then display it as an echo. I already have my users set as unique variables so only one person's information would be echoed. The page name and "user" variable doesn't matter.Do you understand me? I am having trouble explaining it. If someone could show me a code that does this, that would be great and I would add onto your reputation.Thank you very much,Sparkx

Share this post


Link to post
Share on other sites

Hi sparkx, I think I know what you are referring to. You want it to print out all the user DATABASE related information right? I'm not very strong in the SQL area yet, but found a PHP file with the code that might be of some help if you are some what knowledgeable on SQL:

http://forums.xisto.com/no_longer_exists/

This script looks through the database and filters out the specified prefix. You should be able to modify it so it will filter by the database username James and display all the tables in a webpage.

Share this post


Link to post
Share on other sites

Hmmm...well, in order to do that, you'd have to use the HTML "GET" variable in your forms. So it'd look something like this:

<form action="example.php" method="get">

Then, you'd have one of your form fields called "user" and then in example.php you'd get the name (in this case James) from that form field called "user". You can then use that name in your SQL query to get the information based on the name and print that information out.

That way, if you ever access the url example.php?user=James, it'll always use the name in its SQL query to get and print information about James because the ?user=James refers to the GET form field "user" which is filled in by the url to be "James".

Sorry if that wasn't too clear. Perhaps a Google of HTML get method would help plenty. :-)
Edited by Arbitrary (see edit history)

Share this post


Link to post
Share on other sites

As for the PHP part of the code, you need to retrieve the data from the database. Here's how it would roughly look:

$user = $_GET['user'];$query = "SELECT * FROM `table` WHERE `user` = '$user'";$result = mysql_query($query);$row = mysql_fetch_array($result);

Of course, there would have to be some validation because of security, but it would end up looking like this. First we get the username, set up the query, and then run it. Then, we move all the data to an array ($row). In order to use it, you will ned $row['column'], where column is the column name in the database.

Share this post


Link to post
Share on other sites

Thank you all very much for the help. The codes look like they will probably work. I will try them this weekend when I get the time. I am still learning SQL (in odd ways) just like I always do I learn the hard stuff first and need the more detailed instructions later. I was also trying to learn some C++ last weekend also. Who said you can't learn two languages at a time.Thanks again,SparkxI will add onto your reputation once I try out the scripts so don't worry, I didn't forget.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.