Jump to content

How to unset $_POST, if page gets reloaded it does not re-send


Recommended Posts

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

 

???

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>";
   }
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.