Forum Moderators: coopster

Message Too Old, No Replies

php and mysql

         

dave1236

6:31 pm on Sep 30, 2004 (gmt 0)

10+ Year Member



Everyone here has been very helpful in answering my previous questions, so now I pose my most difficult one yet...

Here is the setup:
1) I use PHP
2) I have a MySQL database setup.

Here is the issue:

Currently, I have a drop down menu that assigns a nme to a selection. This name is then passed to a new page via the following:
<?php print $_POST[ABC];?>

I am looking to implement a user registration process that would do one of the following:
1) either replace the <?php print $_POST[ABC];?> entirely with the user id, or
2) append the userID to the <?php print $_POST[ABC];?> command in the page that is opened.

My goal is to be able to identify a particular user when applicable, and if they have not/do not want to register, still allow them to utilize the site.

I am thinking the best way would be to have the php look for a cookie and if one does not exist (or is created via a login) then to default to the single POST[ABC] command.

Suggestions?

coopster

10:45 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sounds like a good plan to me ;)

dave1236

12:49 am on Oct 1, 2004 (gmt 0)

10+ Year Member



Coopster:

Good to hear from you...I remember you as being very helpful in the past. Since you agree with the premise of how I am trying to do this, which method would you recommend?

coopster

2:42 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If it's a simple login (no security necessary, etc.) then Cookies would work just fine. If the user won't accept a cookie, you'll have to append things in the url or use the <input type="hidden"> strategy. One way or another you'll have to maintain state if you want to identify each and every visitor.

If you are going to get into user registration and tracking, I would encourage you to dig into session management. Sooner or later you are proabably going to want to use this type of feature and now is as good a time as any to learn about PHP's Session Handling Functions [us4.php.net].

If sessions are too much for this particular project, at least you will have a better understanding how cookies function in PHP.