Approve or Deny Buttons

I wasn’t really sure where to post this question, because I am using a few different languages. I’m creating a lightbox with javascript and ajax and, but I want to update mysql with php.

The approve button has a name like… approverequest[2]
The delete button has a name like… denyrequest[2]
where 2 is the users id

My problem is that I can’t get the data to update in mysql. Am I going about this the wrong way?



Code: [Select]

if (isset($_POST['acceptrequest']))
{
	if (is_array($_POST['acceptrequest'])) {
		$keys = array_keys($_POST['acceptrequest']);
		$id = $keys[0];
		
		$sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id' AND `friend_id` = {$user_info['uid']}";
		header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
	}
}
else if (isset($_POST['denyrequest']))
{
	if (is_array($_POST['denyrequest'])) {
		$keys = array_keys($_POST['denyrequest']);
		$id = $keys[0];
		
		$sql = "UPDATE `partners` SET `approved` = -1, `approved_date` = NOW() WHERE `user_id` = '$id' AND `friend_id` = {$user_info['uid']}";
		header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
	}
}

if (isset($sql) && !empty($sql))
{
	mysql_query($sql);
}

Try putting the header() after the statement that runs the query.

And you could try to echo out $sql to see what the query looks like.

Can you do a:

var_dump($_POST);

and post its output? var_dump should give you an idea about how to find the id.