Jump to content

Accept of Deny Lighbox Buttons


unemployment

Recommended Posts

I have created a lightbox where you can accept of deny friends.  Each friend that is displayed has approved or deny buttons next to them.

 

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?

 

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'";
	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'";
	header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
}
}

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

Link to comment
https://forums.phpfreaks.com/topic/234252-accept-of-deny-lighbox-buttons/
Share on other sites

I think you forgot something

 

<?php
$sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'";
// after the previous line, you have to do this next line to update ur table

mysql_query($sql);
?>

 

I don't think so because I am using...

 

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

 

UPDATE:  I forgot to add in friend_id

 

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'] );
}
}

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.