954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

getting user info

hello all. i am writing a php / mysql script that does various things, but in addition to those things i need it to get the username of whoever is using the front end. any help is greatly appreciated! also i can post some code snippets if you want a feel for what im doing.

sickly_man
Light Poster
42 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Do you mean you need the user to submit their name?

If so you could just use and HTML form and post it to your php page for processing.

Cerberus
Junior Poster
162 posts since Sep 2006
Reputation Points: 27
Solved Threads: 14
 

no. everyone in my office (like 9 people total) has a Unix username they have to use to log into our company website. the website has stuff like a calendar of events, technical info, various forms for things, and it will have the IP database front end i am writing for it. when a user uses this new front end i want it to get his or her username because it will go into a row in the IP table (telling other users who inserted that row of data). does that clear it up a little bit? thanksa.

sickly_man
Light Poster
42 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

You could possibly store the username in the session variable after a successful login and then insert that value in the table.

Cerberus
Junior Poster
162 posts since Sep 2006
Reputation Points: 27
Solved Threads: 14
 

ok. they will only be using my front end if they've logged in successfully, so we can assume that all logins were successful. how would i go about doing that? thanks!!

sickly_man
Light Poster
42 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Post (method="post") the html control data e.g. txtusername, txtpassword to your php page. Then on your php page you need to start_session() (or something like that) and then assign a value to the session variable e.g. $_SESSION['varUserName'] = $_POST[txtusername].

Now you can access that variable while the session is live.

e.g.

<?php
    echo $_SESSION['varUserName'] //output user name
?>


My php is a bit rusty so it might not be exact.

Cerberus
Junior Poster
162 posts since Sep 2006
Reputation Points: 27
Solved Threads: 14
 

ok i think i understand the second part of what you said. but how do i post the php control data (txtusername, txtpassword) to my php page? i really am new to php and appreciate all the help.

sickly_man
Light Poster
42 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

It's not too difficult. Say you had a login page with two text areas (username and password) and a button (submit) you would use an HTML form like this...


username

password:

When you click submit the text box input is sent to authenticate.php.

Cerberus
Junior Poster
162 posts since Sep 2006
Reputation Points: 27
Solved Threads: 14
 

i really dont wanna do that because when the user is using my IP database front end they will already have logged in to the server (//gothics). im asking how i can get that information that they've already given the server so i can identify who is making what modifications to the IP database. is there a way to do that? sorry if im being a pain.

sickly_man
Light Poster
42 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

There might be another way but i only know the method that i've explained above.

Cerberus
Junior Poster
162 posts since Sep 2006
Reputation Points: 27
Solved Threads: 14
 

ok. some of what you said was helpful.....so thanks dude/dudette!

sickly_man
Light Poster
42 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

If they have already logged in to some other page before getting to your front end, the user info may already be in the session. Can you ask the developers of the other system about that? They can probably pass any session info you need via the link to your page.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

You could probably use cookies?

The user logs in once, then a cookie containing his/her username is stored in the computer. When the user enters info into a row, with php code you get the username from the cookie and you can store it into your database.

$user = $_COOKIE["name_of_the_cookie"];

blex41
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You