When you click on someone's profile, I have a script, that checks if a logged in member and another "friend" are already friends, if not I want to send them to a page that allows them to add the friend. I also pass over the friends id ($requestedid) in a GET variable:
in my profile.php?id=$id page I have
//connect to db blah blah
if($isfriendcheck > 0){
echo "$id and $logOptions_id are already friends! <br />";
} else {
$requestedid = $id;
header("location: friendrequest.php?requestedid=$requestedid");
}
in friendrequest.php I have:
<?php
session_start();
//include_once("scripts/checkuserlog.php");
$requestedid = $_GET[requestedid];
if ($_GET['id']) {
$id = $_GET['id'];
} else if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
} else {
include_once "index.php";
exit();
}
if ($_POST[Submit4]) {
//echo "you ($id) and friend ($requestedid) did not post";
include_once "scripts/connect_to_mysql.php";
$sql = mysql_query("INSERT INTO friends (requesting_id, requested_id, request_time)
VALUES('$id', '$requestedid', now())") or die (mysql_error());
echo "You ($id) have successfully sent a friend request to friend ($requestedid)...";
exit();
}
?>
Here's the form:
<body>
<form action="friendrequest.php" method="POST" enctype="multipart/form-data">
<table width="900" border="0" style="background-color:#F2F2F2; border:#999 1px solid;" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php echo "You ($id) and this member ($requestedid) are not friends... <br/>";?>
<input type="submit" name="Submit4" value="Send Friend Request" />
</td>
</tr>
</table>
</form>
</body>
What's happening is when it comes to $POST[Submit4], the $requestedid = $GET[requestedid] variable is not being passed...
Can anyone solve this or show me a better way.... thanks