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
https://forums.phpfreaks.com/topic/99011-friend-request/
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
https://forums.phpfreaks.com/topic/99011-friend-request/#findComment-506662
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
https://forums.phpfreaks.com/topic/99011-friend-request/#findComment-506668
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.