unsider Posted April 1, 2008 Share Posted April 1, 2008 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. Quote Link to comment Share on other sites More sharing options...
unsider Posted April 1, 2008 Author Share Posted April 1, 2008 Still fooling around with it, but no luck. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 1, 2008 Share Posted April 1, 2008 What is the problem? You pretty much have the link setup correctly. echo "<a href='friendrequest.php?user=$user[profileusername]'>Add as Friend</a>"."<br>"; If $user holds the username you want, I don't understand the problem. Quote Link to comment Share on other sites More sharing options...
unsider Posted April 1, 2008 Author Share Posted April 1, 2008 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 Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 1, 2008 Share Posted April 1, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.