Jump to content

Archived

This topic is now archived and is closed to further replies.

flower.jason

Members Db

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.