Alternative page for "After deleting, go to:"
Hi!
Got a PHP dynamic list page that lists records from two tables in MySql database, the tables got a column named "gk" that makes them different from each other. In one table gk is allways "ÖGK" and in the other table gk is allways "PGA".
Now, in the list page there are a number of buttons that links to insert, update and delete pages. These pages are duplicated for each of the two tables, for example there are one delete record page for a record in the table with ÖGK in the gk column (delete_user.php) and another delete record page for a record in the table with PGA in the gk column (delete_user_pga.php). Actually there are two lis pages to, one list_users.php mentioned obove, this is the master list page with the problem. And one list_users_pga.php that lists only records from PGA table, no problem here.
I got this working so far that I get to the right delete record page (the one that deletes from the corect table ÖGK or PGA), and the record wil be deleted whith this home grown code:
input name="Button2" type="button" class="miniknapp" onclick="MM_goToURL('parent','<?php if ($row_listUsers['gk']== "ÖGK") { echo "delete_user.php"; } elseif ($row_listUsers['gk']== "PGA") { echo "delete_user_pga.php"; } else { echo ""; } ?>?id=<?php echo $row_listUsers['id']; ?>');return document.MM_returnValue" value="Delete"
There are no problems if I from the master list page go to a page that delete or update a record from the ÖGK table couse it folows the "After delete, go to" link that is specified in the delete record dialoge. No problems if I go to a delete or update page from the "List only PGA records" for the same reason.
But if I'm deleting a record from the PGA table it will delete the record properly but redirect to the PGA list page. like it's supposed to do if you got to the page from list_users_pga.php. BUT if you got there from the master list page list_users.php I want to be redirected back to that page where I came from. The same problem occures if I cancel the deletion (cancel script from David Powers book "The Essential Guide to Dreamweaver CS4.... Hello David)
Well, tried with a lot of home cocked code pudding without success:
<?php
if ($row_getUsers['gk']== "ÖGK") { // Show if gk = ÖGK
?>
<?php
if (array_key_exists('cancel', $_POST)) {
header('Location: http://teeview.se/analys_kund/list_users.php');
exit;
}
if ((isset($_POST['id'])) && ($_POST['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM analys_kund_pga WHERE id=%s",
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_connect, $connect);
$Result1 = mysql_query($deleteSQL, $connect) or die(mysql_error());
$deleteGoTo = "list_users.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
?>
<?php } // end Show if gk = ÖGK?>
<?php
if ($row_getUsers['gk']== "PGA") { // Show if gk = PGA
?>
<?php
if (array_key_exists('cancel', $_POST)) {
header('Location: http://teeview.se/analys_kund/list_users_pga.php');
exit;
}
if ((isset($_POST['id'])) && ($_POST['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM analys_kund_pga WHERE id=%s",
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_connect, $connect);
$Result1 = mysql_query($deleteSQL, $connect) or die(mysql_error());
$deleteGoTo = "list_users_pga.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
?>
<?php } // end Show if gk = PGA?>
The same scenario will of course happens i register and uppdate pages but the solution will also be the same I guess![]()