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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.