Jump to content

Friend Request


unsider

Recommended Posts

Ok. I am going to try to lay out my problem as clearly as I can.

 

I have:

 

 

userinfo.php

 

// HELP REWRITING ??
echo "<a href='friendrequest.php?user=$user[profileusername]'>Add as Friend</a>"."<br>";

 

 

 

When clicked it executes my friendrequest.php script.

 

// OK, now I'm not quite sure how to go about doing this.

// I need to retrieve the username of that specific page where "Add To Friends" was clicked.

// Ex. Assume you click, Jimmy's "Add To Profile", I have to retrieve the username 'Jimmy'.

// So essentially the username of the person you would like to be friends with. 

 

friendrequest.php

 

<? 
session_start();
include "session.php";  
if(!$session->logged_in) { 

// _______________________________________THIS IS $_GET array_______________________________________________________
// ________________________________________________________________________________________________________________

if ($_GET[user]){ //gets username  
$username = htmlspecialchars($_GET[user]); 

// ________________________________________________________________________________________________________________

$by = $_SESSION['username']; 
$query = mysql_query("INSERT INTO `friend_requests` ( `username` , `by` ) VALUES ( '$username' , '$by' )");
echo ( "$username has been sent a request you must now wait for it to be accepted" );
} else { 
echo ( "No request was made" ); 
} 
} else { 
echo ( "You need to be logged in" ); 
} 
?> 

 

If you have any questions, please ask.

Link to comment
Share on other sites

But that is the problem, it doesn't hold the username I'm looking for. I'm trying to...

 

// I need to retrieve the username of that specific page where "Add To Friends" was clicked.

// Ex. Assume you click, Jimmy's "Add To Profile", I have to retrieve the username 'Jimmy'.

// So essentially the username of the person you would like to be friends with. 

 

Output:

 

I'm logged in, everything if functioning although the URL output is - http://example.com/main/friendrequest.php?user=u

 

Link to comment
Share on other sites

What is wrong with the output URL? Wouldn't "u" be the persons username they want to request to be friends with, or is that the logged in users username?

 

If it's the logged in users, then why don't you just pass the other users username through the URL as well? Make the link like this:

http://example.com/main/friendrequest.php?user=u&request_freind=some_username

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.