Jump to content

Transfering data to a MYSQL database


daverichris

Recommended Posts

Hello,

 

Sorry if I have put this in the wrong category.

 

I have created an "edit user profile" page that can only be accessed once a user has logged in. The form works correctly and sends the data, i.e. name, email, tel number, vital stats to the MYSQL database. However, when it arrives in the database its simply lost in the "profile database" as another row. I want to  include the $user name or something similar so when a another user looks up the profile it will pull that users information on to the page. Does that make sense?

 

But how?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/232229-transfering-data-to-a-mysql-database/
Share on other sites

Seeing as this post didn't directly mention AJAX, my response may be irrelevant...

 

 

Do you mean that you want that profile data to still be visible on the screen after posting? Or you just want to search on usernames?

 

Regardless of the answer to either of those, a pre-requisite of anything useful happening in a mysql table is an auto incrementing id field in your profiles table - and any other table (generally also set as your primary key). Once you have that, you can do just about anything you like.

 

If you want to retrieve the data after insertion, use the command...

 

mysql_insert_id()

 

...In a select statement to retrieve that new record. (ie: "select * from profiles where id= '" . mysql_insert_id() ."'")

 

If you just want to find users that match a certain username in a profile search, you can use a simple select statement like "select * from profiles where username = '" . $username_search . "' order by username"

 

 

 

Hello,

 

Thank you very much for your help, can i pick your brains with a couple more questions.

 

A user enters the "profile" page where they will be able to see their details displayed *(I've not yet put this script together). If they wish to update their profile they may edit profile and are redirected to the "edit profile page". So as you described above i can add in the *mysql_insert_id().

 

However, this will give it an id, but when the user next logs in and wants to view their profile, how will the "profile" page know it needs to pull down that particular id?

 

I just assumed that i would search the user name because that would defiantly be theirs, where as i assumed an id would automaticly increment?

 

Forgive me, this is new to me, teaching myself on bit of a crash course.

 

mike

Archived

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

×
×
  • Create New...

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.