Hi,

I finally figured out how to take a row from a table and display it on a page. Big deal, huh?

That was not exactly my main goal, though.

When a User submits a form I need that data to display. I've struggled with this.

I now figure that I must somehow base submission display on something unique such as a session or a cookie. (?) I really don't know at this point.

Consider this: 100 people submit at once on my site; How do I display the input from that person and not someone else's input data? This is confusing.

100 people submit and 100 people need to view their data; How do I differentiate between all these people and make sure each person sees their own data and not someone else's?

Thank you for your time.
Matthew

How do I display the input from that person and not someone else's input data? This is confusing.

100 people submit and 100 people need to view their data; How do I differentiate between all these people and make sure each person sees their own data and not someone else's?

For you to display the user's data, you have to know who the user is. Are you having user's log in to your web application? If so, you should be tracking them via cookie or session variable. If these are anonymous users, you can still track them during the duration of their visit by accessing the session id. Once they close their browser window, the session is terminated.

If you plan on tracking the user without some athentication method, again... you can do so simply by tracking the session Id. You can store the session id in a database along with the info that they submitted. When the user visits the following page, grab the session id and perform a lookup in the db, and extract the data you need for displaying.

commented: A great help! +7

As JorgeM said your best bet is to use session data. if the preson posting is a user them my advise to you is when a user login store a reference to the user's db in the users session data example will be the user's db id then you can use that to do querys and others on that use's data if the user is anonymos them you can generate a random token to reference that user during the session.

When solving these problems it is adviseable to think of them in terms of one user. Make sure it works for one preson them you can mover on to see if it works for two. Web servers are like any computer programs
they will handle one user at a time. even node which is async will still handle one user at a time (but will not wait for the user's action to finish before attending to an other user)

the request coming form the users contains every thing the server (you) need to handle the request even session data is not stored on the server it is stored in the request so if your logic works for one preson it will pretty well work for 100 users

commented: A great help! +7

JorgeM and otengkwaku:

Thank you so much for your suggestions and help - I greatly appreciate it and still must research it further, but I am leaning towards using sessions.

Now, a session is created upon login for the User? This session can be stored as a unique identifier for that user which can then be called again when the User logs in, say for a second session (?).

When this User logs in for a second time, I can run a query based on their login credentials, pointing to their session data which is stored with their account info (?)

Yes, I will spend the time to do some good research on this in the next couple of days and report back here with my results from the updated coding.

Thank you again for your help, Friends!
Regards,
Matthew

here's some additional comments/suggestions that may help you.

If you are not intending to log in users, but do want to track them during the time that they are on your site, all you need to do is work with the sessionid that is created. http://us2.php.net/session_id

While the user is browsing your site, this session_id will remain the same for that user. So say you want to store some information temporarily and retrieve it on different pages on your site, you can store in a database table, the session_id along with additional fields holding data that you are tracking. when a user moves through your site, you simply need to perform a database query based on the session_id, if there is a match in your db table, retrieve the row(s) of data and display it on the page. Once the user closes the browser window, that session_id is done. If the user opens a new browser window and accesses your site, a new session_id is created. So, for tracking users over time and different connections, session_id is not a good choice. It is good for that one time visit to your site.

If you want to track users over different visits, you need to use another approach. A common approach is that you implement a login page to collect information about who is visiting. this is usually a username and password. Assuming that you have already registered the user on your site, meaing that you are already storing the username and password in a db, when a user revisits you in the future, you are going to direct them to a login form. The user provides the username and password and you take in that information and query the database based on that username. if there is a match, you can store some information in a "session variable" such as the user's username. but you can store as much as you wish by creating different session variables. when the user closes the browser, the session variables are gone. When the user opens a new browser and revisits your site, the user will have to login again and the authentication process happens again. You take the username and password and query your db for a match. if there is a match, you once again create session variables and store what ever information you want about that user so that you can access these session variables on different pages on your site.

Say, you want to give the user the ability to login one time and to remain "logged in" unless the user clicks on a "log out" button. This can be easily achieved by having the user login using your form and then rather than just storing the user's info in a session variable, you create a cookie to hold the info. Any time you users access your page(s), you request the cookie and extract the info. So, in this case even if your user closes the browser, when the user opens a new browser window and accesses your site, the user's browser can send the cookie back to your web site. You can read the user's info and not have to have the user login again.

lots of info here... its a good idea if you read up on this some more and come back for more discussion...

hope this helps.

Thank you, Sir. I will read up further on this and report back in due time with any questions/concerns that I may have.

Kind regards,
Matthew

Member Avatar for iamthwee

I would suggest also going through the youtube tutorials. One of my favourites is phpacadamey. Google it and go through each one... this is especially useful for beginners.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.