cs.punk Posted April 10, 2009 Share Posted April 10, 2009 What I am trying to do is UNSET the $_POST so that the if statement returns false... But it seems the browser just 're-sends' the $_POST arrays... if (isset($_POST['apr_ad']) && $_POST['apr_ad'] == "Approve Ad" && isset($_POST['aa_id']) && $_POST['aa_id'] == "$adid" && isset($set)) {$con = mysqli_connect ("$dbhost","$dbuser","$dbpass","$dbname") or die ("Could not connect to server"); $sac = "SELECT * FROM board_posts WHERE ad_id = '$adid'"; $e_sac = mysqli_query($con,$sac) or die ("Could not execute \"SELECT * FROM board_posts WHERE ad_id = '...'\" query." . mysql_error()); $row = mysqli_fetch_assoc($e_sac); $copy = "INSERT INTO ad_posts (cat_id, datetime, ad_title, ad, ad_id) VALUES ('{$row[cat_id]}','{$row[date]}','{$row[ad_title]}','{$row[ad]}','{$row[ad_id]}')"; $e_copy = mysqli_query($con,$copy) or die ("Could not execute \"INSERT INTO ad_posts (...) VALUES (...)\" query." . mysql_error()); $delete = "DELETE FROM board_posts WHERE ad_id = '$adid'"; $e_delete = mysqli_query($con,$delete) or die ("Could not execute \"DELETE * FROM board_posts WHERE ad_id = '...'\" query." . mysql_error()); echo "<p class=\"smallheading\">Ad has sucsessfuly been approved.</p>"; unset ($_POST['aa_id']); unset($_POST); unset ($set); } ??? Link to comment https://forums.phpfreaks.com/topic/153451-how-to-unset-_post-if-page-gets-reloaded-it-does-not-re-send/ Share on other sites More sharing options...
cs.punk Posted April 10, 2009 Author Share Posted April 10, 2009 I got what I wanted like this : <?php if (isset($_POST['apr_ad']) && $_POST['apr_ad'] == "Approve Ad" && isset($_POST['aa_id']) && $_POST['aa_id'] == "$adid") {$con = mysqli_connect ("$dbhost","$dbuser","$dbpass","$dbname") or die ("Could not connect to server"); $sac = "SELECT * FROM board_posts WHERE ad_id = '$adid'"; $e_sac = mysqli_query($con,$sac) or die ("Could not execute \"SELECT * FROM board_posts WHERE ad_id = '...'\" query." . mysql_error()); $row = mysqli_fetch_assoc($e_sac); if ($adid == $row[ad_id]) {$copy = "INSERT INTO ad_posts (cat_id, datetime, ad_title, ad, ad_id) VALUES ('{$row[cat_id]}','{$row[date]}','{$row[ad_title]}','{$row[ad]}','{$row[ad_id]}')"; $e_copy = mysqli_query($con,$copy) or die ("Could not execute \"INSERT INTO ad_posts (...) VALUES (...)\" query." . mysql_error()); $delete = "DELETE FROM board_posts WHERE ad_id = '$adid'"; $e_delete = mysqli_query($con,$delete) or die ("Could not execute \"DELETE * FROM board_posts WHERE ad_id = '...'\" query." . mysql_error()); echo "<p class=\"smallheading\">Ad has sucsessfuly been approved.</p>"; unset ($_POST['aa_id']); unset($_POST); unset ($set); } else {echo "<p class=\"paragraph\">Sorry but this ad does not exsist, it might have already been approved !</p>"; } } Link to comment https://forums.phpfreaks.com/topic/153451-how-to-unset-_post-if-page-gets-reloaded-it-does-not-re-send/#findComment-806479 Share on other sites More sharing options...
Maq Posted April 10, 2009 Share Posted April 10, 2009 I got what I wanted like this : Then please mark as [sOLVED]. Link to comment https://forums.phpfreaks.com/topic/153451-how-to-unset-_post-if-page-gets-reloaded-it-does-not-re-send/#findComment-806670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.