Jump to content


Photo

Members Db


  • Please log in to reply
1 reply to this topic

#1 flower.jason

flower.jason
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 December 2005 - 09:05 AM

Hi,

I have been using php and mySQL for a while now and have had a client ask for something. They have a table with members info already in (a userID, FirstName, LastName, Email, Address, Phone etc.). They want to have these users register, login and be able to change their details. Any ideas on how i should do this.

#2 Zup

Zup
  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationWinnipeg, MB

Posted 07 December 2005 - 07:33 AM

Have them log in with their username and password. Then present them with a form that they can use to edit their info with. Have the form action link to the same page and use the method "post". At the top of your PHP script, do this:
$var = $_POST['var'];
Replace var with your variable names, (ie. $FirstName = $_POST['FirstName'];)
Then connect to your DB and use MySQL to update your members table, like so:
$query = "UPDATE users SET FirstName='$FirstName', LastName='$LastName', Address='$Address', Phone='$PhoneNumber' WHERE userID='$ID'";
@MySQL_Query($query)
  or die ("Error executing query");
Now $ID is going to have to be found when the user logs in since every user should have a unique ID. This can be found with the query:
@MySQL_Query("SELECT userID FROM users WHERE username='$user' AND password='$pass'")
  or die ("Error executing query");
I hope this helps, if you need extra help just ask, but you may have to provide a little more information about your tables and their field names.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users