PDA

View Full Version : Delete recordsets; need a warning...


kona72
05-17-2006, 02:52 AM
Hey,

I have a record set displaying data and i have it using the delete record set command as well. My problem is when the site administrator click the 'delete recordset' link it does it RIGHT NOW; there is no chance to back up or a popup window specifying what the user is doing. I will post the code here....

This is the record set with the link to the delete record set option...

<div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<?php do { ?>
<tr align="left" valign="top">
<td width="24%">Registration Number: </td>
<td width="76%"><?php echo $row_rsReginfo['reg_number']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Registration Type </td>
<td width="76%"><?php echo $row_rsReginfo['reg_type']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Registrants Name: </td>
<td><?php echo $row_rsReginfo['first_name']; ?><?php echo $row_rsReginfo['last_name']; ?> </td>
</tr>
<tr align="left" valign="top">
<td>Group or Company: </td>
<td><?php echo $row_rsReginfo['group_comp']; ?> </td>
</tr>
<tr align="left" valign="top">
<td>Number of Participants: </td>
<td><?php echo $row_rsReginfo['group_num']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Address: </td>
<td><?php echo $row_rsReginfo['address']; ?></td>
</tr>
<tr align="left" valign="top">
<td>City: </td>
<td><?php echo $row_rsReginfo['city']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Province: </td>
<td><?php echo $row_rsReginfo['prov']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Postal Code: </td>
<td><?php echo $row_rsReginfo['postal']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Email:</td>
<td><?php echo $row_rsReginfo['email']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Phone Number: </td>
<td><?php echo $row_rsReginfo['phone']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Business Number: </td>
<td><?php echo $row_rsReginfo['bus_phone']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Cell Number: </td>
<td><?php echo $row_rsReginfo['cell_phone']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Parent/Guardian:</td>
<td><?php echo $row_rsReginfo['consent']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Parent/Guardian Phone: </td>
<td><?php echo $row_rsReginfo['consent_phone']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Comments:</td>
<td><?php echo $row_rsReginfo['comments']; ?></td>
</tr>
<tr align="left" valign="top">
<td>Waiver:</td>
<td><?php echo $row_rsReginfo['waiver']; ?></td>
</tr>
<tr align="left" valign="top">
<td colspan="2"><div align="center"> Edit This Record (edit_reg.php?reg_number=<?php echo $row_rsReginfo['reg_number']; ?>) | Delete this Record (delete_record.php?reg_number=<?php echo $row_rsReginfo['reg_number']; ?>)
<hr>
</div></td>
</tr>
<?php } while ($row_rsReginfo = mysql_fetch_assoc($rsReginfo)); ?>
<tr align="left" valign="top">
<td colspan="2"></td>
</tr>
</table>


<?php echo min($startRow_rsReginfo + $maxRows_rsReginfo, $totalRows_rsReginfo) ?> of <?php echo $totalRows_rsReginfo ?>

">Next (<?php printf() | ">Previous (<?php printf()</p>
<p align="center">Printer Friendly Page For All Records (javascript:;)</p>
</div>

And here is the delete record set page that does the deleteing.....

<?php require_once('../Connections/save.php'); ?>
<?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;
}

if ((isset($_GET['reg_number'])) && ($_GET['reg_number'] != "")) {
$deleteSQL = sprintf("DELETE FROM walk_register WHERE reg_number=%s",
GetSQLValueString($_GET['reg_number'], "int"));

mysql_select_db($database_save, $save);
$Result1 = mysql_query($deleteSQL, $save) or die(mysql_error());

$deleteGoTo = "deleted.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

</body>
</html>

I hope this can be achieved as i have some very click happy admin people who have already delete a number of DB records...

THANKS IN ADVANCE!!!