Jump to content

Add to contacts dillema


clint

Recommended Posts

Good morning  :)

 

I am trying to add an "add to contacts" button to the user profile page that is viewed by other users but I seem to be struggling to wrap my head around this one. I can create the search user page that populates a list of users based on search criteria and link to their respective profiles using GET.

 

But now if I have a "add to contacts" button on their profile page, I am struggling with the code to insert this into a contacts table correctly. If the contacts table has a id column, user_id column and contacts_id column how do I insert the id of the user you are viewing into the contacts_id column?

 

I should have something along these lines....:

 

if (isset($_SESSION['user_id']))

 $user_id = ($_POST['user_id']);

 $sql_insert = "INSERT into `contacts` (`user_id`,`id`,`date`)
  	  	
          VALUES ('".$_SESSION['user_id']."','$id',now())";

mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
$user_id = mysql_insert_id($link); 

 

but that is not going to add the id as contact id for the profile being viewed.

Should this be done totally differently?

 

Any help in this regard would be highly appreciated.

Apologies if I have not explained properly.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/228081-add-to-contacts-dillema/
Share on other sites

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.