shorty3 Posted September 8, 2010 Share Posted September 8, 2010 Right ive got a user profile that i want a add friend button but i coded a little something what i fort wud work but no luck <?php session_start(); include "includes/db_connect.php"; include "includes/functions.php"; include"includes/smile.php"; logincheck(); $username=$_SESSION['username']; $viewuser=$_GET['viewuser']; $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$viewuser'")); if (!$fetch){ echo "No such user"; $totalf = mysql_num_rows(mysql_query("SELECT * FROM friends WHERE username = '$viewuser' AND active='1'")); $invite_text="<div>$username Has Sent You A Friend Request<br> <input name=Yes_Accept type=submit id=yes value=Accept Invite class=abutton> <input name=No_accept type=submit value=Decline Invite class=abutton></div><input type=hidden name=invite_id value=$bar2>"; if (($_GET['fri'])){ $exicst=mysql_query("SELECT * FROM users WHERE username='$viewuser'"); $nums=mysql_num_rows($exicst); $adding=mysql_fetch_object($exicst); $already=mysql_num_rows(mysql_query("SELECT * FROM friends WHERE type='Friend' AND person='$viewuser' AND username='$username'")); if ($already != "0"){ echo "<center><font color=orange><b><br>This user is already your friend.<br><br></font>"; }elseif ($already == "0"){ mysql_query("INSERT INTO `friends` ( `id` , `username` , `person` , `type` , `active`) VALUES ( '', '$username', '$viewuser', 'Friend' , '0' )"); mysql_query("INSERT INTO `friends` ( `id` , `username` , `person` , `type` , `active`) VALUES ( '', '$viewuser', '$username', 'Friend' , '0' )"); mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `subject` , `date` , `read`) VALUES ( '', '$viewuser', '$username', '$invite_text' , 'Friend Request' , '$date' , '0' )"); $bar2=mysql_insert_id(); echo "<center><font color=orange><br>Your Friend Invitation Was Sent To $viewuser<br><br></font>"; exit(); } }} ?> <a href=?fri=Yes>Add Friend +</a> It just adds a blank person and comes back with No Such User and Your Friend Invitation Was Sent To I think ive put some things in the wrong place to be honest but as im not a pro i easily miss things Quote Link to comment Share on other sites More sharing options...
winelover Posted September 8, 2010 Share Posted September 8, 2010 Is your method correct on the page before? Quote Link to comment Share on other sites More sharing options...
shorty3 Posted September 8, 2010 Author Share Posted September 8, 2010 Not to sure what you mean but the profile was fine before i started to try and add a friend button The profile is not my problem its the add friend feature i want Quote Link to comment Share on other sites More sharing options...
winelover Posted September 8, 2010 Share Posted September 8, 2010 You are using the get-method. $viewuser=$_GET['viewuser']; Does the link on the 'add friend'-button include the variable 'viewuser'? Like this: <INPUT TYPE="BUTTON" VALUE="Add Friend" ONCLICK="window.location.href='thepage.php?viewuser=shorty3'"> Quote Link to comment Share on other sites More sharing options...
shorty3 Posted September 8, 2010 Author Share Posted September 8, 2010 Its <?php echo "<a href='?fri=$viewuser'>Add Friend +</a>"; ?> Its Not In Button Form as i want to make my own button once its coded correctly eg. <?php echo "<a href='?fri=$viewuser'><img src='image.jpg'></a>"; ?> Quote Link to comment Share on other sites More sharing options...
winelover Posted September 8, 2010 Share Posted September 8, 2010 Change $viewuser=$_GET['viewuser']; into $viewuser=$_GET['fri']; 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.