Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

Deleting a record and redirecting

Posted 31 Aug 2007 10:09:06
1
has voted
31 Aug 2007 10:09:06 Greg Vantyghem posted:
Hi,

I'm trying to redirect to a page, after an update, insert or deleting of a record.

The update, insert or deleting of a record works fine, but I get a blank page instead of my redirect page (list of records).

Thx in advance for your help !

Greg


Here is the code:



<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

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

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1") {
$updateSQL = sprintf("UPDATE ProductGroup SET ProductGroupName=%s WHERE ProductGroup_ID=%s",
GetSQLValueString($_POST['ProductGroupName'], "text",
GetSQLValueString($_POST['ProductGroup_ID'], "int");

mysql_select_db($database_Duco_Referenties, $Duco_Referenties);
$Result1 = mysql_query($updateSQL, $Duco_Referenties) or die(mysql_error());

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

$colname_Recordset1 = "-1";
if (isset($_GET['recordID'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_Duco_Referenties, $Duco_Referenties);
$query_Recordset1 = sprintf("SELECT ProductGroup_ID, ProductGroupName FROM ProductGroup WHERE ProductGroup_ID = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Duco_Referenties) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

Edited by - DUCO_DESIGN on 31 Aug 2007 10:23:25

Reply to this topic