Copy link to clipboard
Copied
I've done this before successfully several times but now something strange is happening. I've stared at this for a couple of hours now and don't see what I'm missing, it must be something blindingly obvious.
I created a page showing all records in a table using a repeating region. I added a column with a big red X image so that users can delete the record by clicking on the "X". This links to a delete page which displays the record and asks "Are you sure" the user clicks "Yes" and the record should be deleted.
What's happening is when the user clicks on the big red X the record is deleted and control is returned back to the page showing all records. I know it's going to the confirmation page as I tried removing the Delete Record behavior and it successfully displays the record I want to delete. I tried creating a new delete page from scratch to delete the record just in case there was something left over from the page I started with to create the delete page in the first place, same result.
Anyone have any clues? I'm using DW CS4, PHP, MySQL and Win 7
Thanks
Better add the Delete Record Server Behavior to "deletedinner.php" and (in the current page) add a hidden field (named "reservationnumber" for instance) to the "are you sure" form which stores the $_GET['reservationnumber'] value.
As your form uses the POST method, the "deletedinner.php" Delete Record Server Behavior needs to check against the value of the hidden field ($_POST['reservationnumber'])
Copy link to clipboard
Copied
I've stared at this for a couple of hours now and don't see what I'm missing, it must be something blindingly obvious.
Perhaps it's obvious but unfortunately no one here can see your code since you've failed to provide it in your post.
Anyone have any clues?
It's difficult to have a clue until you get a clue and post the code in question. No mind readers here.
Copy link to clipboard
Copied
oops sorry, here's the code for the delete page
<?php require_once('../Connections/adminconnection.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['reservationnumber'])) && ($_GET['reservationnumber'] != "")) {
$deleteSQL = sprintf("DELETE FROM dinner WHERE reservationnumber=%s",
GetSQLValueString($_GET['reservationnumber'], "int"));
mysql_select_db($database_adminconnection, $adminconnection);
$Result1 = mysql_query($deleteSQL, $adminconnection) or die(mysql_error());
$deleteGoTo = "admin2.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_rsdeletedinntest = "-1";
if (isset($_GET['reservationnumber'])) {
$colname_rsdeletedinntest = $_GET['reservationnumber'];
}
mysql_select_db($database_adminconnection, $adminconnection);
$query_rsdeletedinntest = sprintf("SELECT * FROM dinner WHERE reservationnumber = %s", GetSQLValueString($colname_rsdeletedinntest, "int"));
$rsdeletedinntest = mysql_query($query_rsdeletedinntest, $adminconnection) or die(mysql_error());
$row_rsdeletedinntest = mysql_fetch_assoc($rsdeletedinntest);
$totalRows_rsdeletedinntest = mysql_num_rows($rsdeletedinntest);
?>
<!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>Untitled Document</title>
<link href="../styles/thrColLiqHdr.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColFixCtrHdr">
<div id="container">
<div id="header">
<h1>Header</h1>
<!-- end #header --></div>
<div id="mainContent">
<h1> Main Content </h1>
<p>L</p>
<p> </p>
<table width="400" border="1">
<tr>
<td>res name</td>
<td><?php echo $row_rsdeletedinntest['reservationname']; ?></td>
</tr>
<tr>
<td>num in pty</td>
<td><?php echo $row_rsdeletedinntest['numberinparty']; ?></td>
</tr>
<tr>
<td>paid</td>
<td><?php echo $row_rsdeletedinntest['amountpaid']; ?></td>
</tr>
</table>
<p> </p>
<p> </p>
<form id="form1" name="form1" method="post" action="deletedinner.php">
<label>are you sure
<input type="submit" name="delete" id="delete" value="Submit" />
</label>
</form>
<p> </p>
<p>Donec nec libero.</p>
<h2>H2 level heading </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>
<!-- end #mainContent --></div>
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>
<?php
mysql_free_result($rsdeletedinntest);
?>
Copy link to clipboard
Copied
Better add the Delete Record Server Behavior to "deletedinner.php" and (in the current page) add a hidden field (named "reservationnumber" for instance) to the "are you sure" form which stores the $_GET['reservationnumber'] value.
As your form uses the POST method, the "deletedinner.php" Delete Record Server Behavior needs to check against the value of the hidden field ($_POST['reservationnumber'])
Copy link to clipboard
Copied
Thank you Gunter, you pointed me in the right direction. There were two errors, the first you correctly identified was the "hidden
field" which I had failed to include in the form and the second was in the Delete Record Server Behavior, it was already defined but I had selected URL variable and not Form field as the key to be deleted.
I really appreciate your assistance.
Tony
Find more inspiration, events, and resources on the new Adobe Community
Explore Now