$act = $_GET['act'];
$entry = $_GET['entry'];//the id of the entry
if($act == 'approve') {
$query = "SELECT * FROM poffers WHERE id=$entry";
$result = mysql_query($query);
$data = mysql_fetch_array($result,MYSQL_ASSOC);
$sql2 = "INSERT INTO coffers (username,offer_name) VALUES ('$data['username']' , '$data['offer_name']' , '$data['offer_type']')";
$sql2run = mysql_query($sql2);
//remove it from the old table
$delete = "DELETE FROM poffers WHERE id=$entry LIMIT 1";
$delrun = mysql_query($delete);
$hits = mysql_num_rows($delrun);
if($hits == '1') {
echo 'The offer' .$entry.'has been removed from pending offers and has been moved to completed offers.';
}
}
}
?>
That is the basics if all goes well. At least you should check to see if the INSERT was successful before doing the DELETE. Better would be to make it all a transaction.
<?PHP
include "../includes/session.php";
else {
/*the action page.all actions of the admin will be redirected here.
That is all*/
$act = $_GET['act'];
$entry = $_GET['entry'];//the id of the entry
if($act == 'approve') {
$query = "SELECT * FROM poffers WHERE id=$entry";
$result = mysql_query($query);
$data = mysql_fetch_array($result,MYSQL_ASSOC);
$sql2 = "INSERT INTO coffers (username,offer_name) VALUES ('$data['username']' , '$data['offer_name']' , '$data['offer_type']')";
$sql2run = mysql_query($sql2);//inserts the offer to completed table.
//remove it from the old table
$put = mysql_num_rows($sql2run);
/*This is what i added in about what you said*/
if($put == 1) {
$delete = "DELETE FROM poffers WHERE id=$entry LIMIT 1";
$delrun = mysql_query($delete);
$hits = mysql_num_rows($delrun);
if($hits == '1') {
echo 'The offer' .$entry.'has been removed from pending offers and has been moved to completed offers.';
}
}
}
}