Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post

    PHP to enter mysql data

    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)

  • #2
    New Coder
    Join Date
    Oct 2007
    Posts
    84
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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
    Code:
    UPDATE table SET userID = $idnumber WHERE username = '$username'

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    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?

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    84
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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.

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    59
    Thanks
    9
    Thanked 1 Time in 1 Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •