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
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>

Link to comment
Share on other sites

well all i know is when i last tested the code, it worked fine, but now i was just testing again to make sure it work, well it was doing that i haven't edited anything :S

 

im checking my database to see if it missed anything while inserting data into mysql

Link to comment
Share on other sites

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

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.