Jump to content

can't get this working :S


zhshero

Recommended Posts

Can someone help me get this working

 

   <?php 

include "sessionStore.php"; 

$userfinal = get_username($_SESSION['user_id']);

if ($userfinal[username]) { //checks user is logged in
switch ($_GET[friends]) { //allows multiple pages
default:
$get = mysql_query( "SELECT * FROM `friend_requests` WHERE `username` = '$userfinal' "); //gets requests
while ($reqs = mysql_fetch_array($get))
{

echo ( "Friend Requests
$reqs[by] wants to be friends with you.
<a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/>
<a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links
}
break;

case 'accept': //accept page
if ($_GET[user]) { //get username

$add = mysql_query( "INSERT INTO `friends` (`friendname` , `username`, `added`) VALUES ('$_GET[user]' , '$userfinal' , '1') "); // add to your friends list
$delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request
echo ( "$_GET[user] has been added as a friend and the request has been deleted" ); // echos the completion
}
break; //ends accept page

case 'delete': // delete page
if ($_GET[user]) { //gets username
$delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request
echo ( "$_GET[user]'s request has been deleted" ); // echos completion
}
break; //ends delete page
} // ends switch
} else {
echo ( "You need to be logged in" ); // not logged in
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/
Share on other sites

sorry

this supposed to grab friend requests from the database

it for accepting new friends or deleting the friend request

 

but when i click accept i notice that url to accept that user isn't working right

<a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/>
<a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links

 

its jsut showing up like this

newfriends.php?friends=delete&user=

when there should be a username beside $user=<username>

takes forever to load phpmyadmin -,-

i beleive there nothign wrong with that code

 

since it failed to insert by into the database

<?
    include "sessionStore.php"; 



$Username = $_GET['username'];
$user = mysql_query("SELECT * FROM users WHERE Username = '$Username'");
$user=mysql_fetch_assoc($user);
$userfinal = get_username($_SESSION['user_id']);
$by = $userfinal; //you
$query = mysql_query("INSERT INTO `friend_requests` ( `username` , `by` ) VALUES ( '$Username' , '$by' )"); //inserts the request
echo ( "$username has been sent a request you must now wait for it to be accepted" ); //echos completion

?> 

to me i don't really see a probably with this, tho it might not be secure tho

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.