URL Variables being reused in form post

134 Views Asked by At

Apologies if this has already been answered or is a simple solution. I have tried searching for weeks for the answer to this problem on here and many other sites.

The problem I have is that URL variables are automatically being reused.

What happens is this:

  1. Submit Update Record form from PAGE1 and after processing go to PAGE2.php?variable1=true

  2. on page 2 which then shows the appropriate information. We then submit another Update Record form on PAGE2 which after processing should go to PAGE3.php?variable2=true.

However what happens is that in reality it is reusing the first variable and goes instead to PAGE3.php?variable2=true&variable1=true

My question is how to prevent the previous url variable being attached automatically to the new one?

Many thanks in advance.

The form code is:

<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="bannerlinks" id="bannerlinks">
          <input name="username" type="hidden" id="username" value="<?php echo $row_loggedin['username']; ?>" />
          <input name="lastlogon" type="hidden" id="lastlogon" value="<?php echo $date ?>" />
          <input name="iconlinks" type="image" id="iconlinks" src="/assets/icon_links.gif" alt="Go to the Links Section" align="middle" />
          <input type="hidden" name="MM_update" value="bannerlinks">
        </form>

The action code is:

editFormAction = $_SERVER['PHP_SELF'];
if (is$set($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "bannerlinks")) {
  $updateSQL = sprintf("UPDATE members SET lastlogon=%s WHERE username=%s",
                       GetSQLValueString($_POST['lastlogon'], "date"),
                       GetSQLValueString($_POST['username'], "text"));

  mysql_select_db($database_Bootshare, $Bootshare);
  $Result1 = mysql_query($updateSQL, $Bootshare) or die(mysql_error());

  $updateGoTo = "/links/index.php?action=Date";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
0

There are 0 best solutions below