Click to See Complete Forum and Search --> : user login system - should be an easy question


jbu311
12-29-2006, 01:45 PM
Hi everyone,

I created a login page, and from the login page my users visit their user homepage. From the user homepage I want them to be able to "post a job." My question is, when they click on "post a job" it will take them to the form that asks for necessary job information, but what is the best way for the form to realize what user is making the submission? I want to put the job record into my mysql database, but have to associate the record with the user that's logged on. What's the best way to get that information?

Thanks in advance,
jbu

NightShift58
12-29-2006, 03:00 PM
Upon completion/submission of the login form/page, you'll only have one basic way to capture the user name - which is to use $_POST['username'] (or whatever name you used in the form).

That information will be available to your script in the page called by the <form action='xxx.php' ...> in your login page and not in the login form page itself.

What you do after that to "remember" the user name is up to you. You have several option. You can use session variables, cookies, add the user name or user ID to the URL or - if your user dialog is based entirely on forms - add the user name/ID as a hidden input on every form.

I think you're probably better off using session variables but that's a subjective call. Others will have differing views. You'll need to see what fits best in your application.