...

View Full Version : PHP to enter mysql data



Doom87
11-05-2007, 01:41 AM
ok so i have a form on one page that will be used to enter an account username and password combination. from there it puts that info into a mysql database. the form submits and opens a popup window. on that popup window it assigns that user their user identification code. how can i have that code saved in the mysql database with that user? (ie. make sure the username and the user identification code match up correctly)

toddandrae
11-05-2007, 02:11 AM
Two ways.

Have the number created at the time of insertion, either by setting a column to auto increment, or by creating your own id and inserting it in the original query.

OR

Updating afterwards

UPDATE table SET userID = $idnumber WHERE username = '$username'

Doom87
11-05-2007, 02:31 AM
i'll do the afterwards method.

for that do i just paste that code there and it will insert the variable $idnumber for the given username?

and is that the complete code listed above?

toddandrae
11-05-2007, 02:38 AM
It is in no way complete. What you will have to do with the afterwards method is either

a)Retrieve the last id from the DB and increment it and then update your new record

OR

b)Generate a unique ID, double check it doesn't exist and then update your new record

I would highly recommend going with the AT TIME OF INSERTION method. Cuts down on code and overhead. All you have to do is modify your table structure to add a ID column with an auto increment.

Doom87
11-05-2007, 02:48 AM
ya i just figured it out. thanks for ur help. ending up doing it at time of insertion & sent it to the next page as a string



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum