Skip to main content
ElizabethGailLittle
Inspiring
May 17, 2012
Question

After Deleting, GoTo

I have a selection page showing filtered records from a table.  When I click Delete (column in display table), I go to a confirmation page.  When I click delete, the record is deleted, but instead of then going to the page specified, it displays the delete page again with the same parameters originally sent.  How can I get it to go back to the filtered display?  I have specified both the page AND add the parameter for the filter.  I've done and redone, but can't get back to the page.

This topic is closed to new replies. Start a new post to keep the conversation going.

12 replies

ElizabethGailLittle
Inspiring
May 19, 2012

GLADLY!  Thanks for the response!

  <div id="mainContent">

    <h1> </h1>

    <h1>Delete Text from <?php echo $varpageSend?> Page</h1>

  <form id="form1" name="form1" method="post" action="">

    <p> </p>

    <p>

      <input type="hidden" name="home_key" id="num_key" value=<?php echo $row_rsText['home_key']; ?>/>

      <input type="hidden" name="varpageSend" id="hiddenField" value=<?php echo $row_rsText['textpage']; ?>/>

    </p>

    <p span class="LgBlueHdr"><?php echo $row_rsText['p_heading']; ?></span></span>

    </p>

    <p> </p>

    <p span class="LgBlueHdr"><?php echo $row_rsText['p_text']; ?></span></span></p>

    <p> </p>

    <p> </p>

    <p> </p>

    <table width="500" align="center" border="1" cellspacing="1" cellpadding="1">

      <tr>

        <td class="GreenHdrGray"><a href="TextPageDisplayAll.php?varpage=<?php echo $row_rsText['textpage']; ?>">Cancel & Return to Display</a></td>

        <td><input name="Delete" type="submit" class="RedHdrRv" id="Delete" value="Delete This Entry" /></td>

      </tr>

    </table>

<p> </p>

    <p> </p>

  </form>

  <p> </p>

    <!-- end .content --></div>

Translate
Community Expert
May 19, 2012

What language?  Can you post the code you have that's not redirecting properly?

Translate
ElizabethGailLittle
Inspiring
May 21, 2012

SORRY!  I send only the body of my code, and you couldn't tell what's going on without the whole file!

Many thanks for any help!

Gail

<!-- filename = DeleteText.php -->

<?php require_once('Connections/sainttim.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

if (isset($_GET['varpage'])) {

  $varpage_rsText = $_GET['varpage'];

  $varpageSend = $_GET['varpage'];

}

if ((isset($_POST['home_key'])) && ($_POST['home_key'] != "")) {

  $deleteSQL = sprintf("DELETE FROM Homepage_text WHERE home_key=%s",

                       GetSQLValueString($_POST['home_key'], "int"));

  mysql_select_db($database_sainttim, $sainttim);

  $Result1 = mysql_query($deleteSQL, $sainttim) or die(mysql_error());

  $deleteGoTo = "TextPageDisplayAll.php?varpage=<?php echo $varpageSend ?>";

  if (isset($_SERVER['QUERY_STRING'])) {

    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";

    $deleteGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $deleteGoTo));

}

$colname_rsText = "-1";

if (isset($_GET['recid'])) {

  $colname_rsText = $_GET['recid'];

}

mysql_select_db($database_sainttim, $sainttim);

$query_rsText = sprintf("SELECT * FROM Homepage_text WHERE home_key = %s", GetSQLValueString($colname_rsText, "int"));

$rsText = mysql_query($query_rsText, $sainttim) or die(mysql_error());

$row_rsText = mysql_fetch_assoc($rsText);

$totalRows_rsText = mysql_num_rows($rsText);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Delete Text</title>

<link href="css/oneColFixCtrHdr.css" rel="stylesheet" type="text/css" />

<link href="css/main.css" rel="stylesheet" type="text/css" />

</head>

<body class="oneColFixCtrHdr">

<div id="container">

  <!-- include file has header and menu -->

          <?php require_once('AdminIncludeHead.php'); ?>

  <div id="mainContent">

    <h1> </h1>

    <h1>Delete Text from <?php echo $varpageSend?> Page</h1>

  <form id="form1" name="form1" method="post" action="">

    <p> </p>

    <p>

      <input type="hidden" name="home_key" id="num_key" value=<?php echo $row_rsText['home_key']; ?>/>

      <input type="hidden" name="varpageSend" id="hiddenField" value=<?php echo $row_rsText['textpage']; ?>/>

    </p>

    <p span class="LgBlueHdr"><?php echo $row_rsText['p_heading']; ?></span></span>

    </p>

    <p> </p>

    <p span class="LgBlueHdr"><?php echo $row_rsText['p_text']; ?></span></span></p>

    <p> </p>

    <p> </p>

    <table width="500" align="center" border="1" cellspacing="1" cellpadding="1">

      <tr>

        <td class="GreenHdrGray"><a href="TextPageDisplayAll.php?varpage=<?php echo $row_rsText['textpage']; ?>">Cancel & Return to Display</a></td>

        <td><input name="Delete" type="submit" class="RedHdrRv" id="Delete" value="Delete This Entry" /></td>

      </tr>

    </table>

<p> </p>

    <p> </p>

  </form>

  <p> </p>

    <!-- end .content --></div>

  <p><br class="clearfloat" />

<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->

   

  </p>

  <div id="footer">Copyright &copy;2010<br />St. Timothy's Episcopal Church<br />All Rights Reserved

  <!-- end #footer --></div>

  <!-- end .container --></div>

</body>

</html>

<?php

mysql_free_result($rsText);

?>

Translate