bigbird3156
Programmer
Hi,
I'm a PHP noob, who is learning on the fly so please be patient... I am trying to create a record delete page for my database and through using dreamweaver and looking at various tutorials and stuff I have developed a page that should delete the record displayed and then redirect you to a confirmation page... only problem is that when you hit the delete button it seems to only reload the current page showing the record you want to delete (and no the record is not deleted from the database)
could someone please look at my code and give me an idea of where I have gone wrong...
Thanks Heaps for any help
The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!!
I'm a PHP noob, who is learning on the fly so please be patient... I am trying to create a record delete page for my database and through using dreamweaver and looking at various tutorials and stuff I have developed a page that should delete the record displayed and then redirect you to a confirmation page... only problem is that when you hit the delete button it seems to only reload the current page showing the record you want to delete (and no the record is not deleted from the database)
could someone please look at my code and give me an idea of where I have gone wrong...
Code:
<?php require_once('../Connections/CA_database.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($HTTP_GET_VARS['rec_num'])) && ($HTTP_GET_VARS['rec_num'] != "") && (isset($HTTP_POST_VARS['Submit']))) {
$deleteSQL = sprintf("DELETE FROM products WHERE rec_num=%s",
GetSQLValueString($HTTP_GET_VARS['rec_num'], "int"));
mysql_select_db($database_CA_database, $CA_database);
$Result1 = mysql_query($deleteSQL, $CA_database) or die(mysql_error());
$deleteGoTo = "admin_delete3.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_del_record = "1";
if (isset($HTTP_POST_VARS['rec_num'])) {
$colname_del_record = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['rec_num'] : addslashes($HTTP_POST_VARS['rec_num']);
}
mysql_select_db($database_CA_database, $CA_database);
$query_del_record = sprintf("SELECT * FROM products WHERE rec_num = %s", $colname_del_record);
$del_record = mysql_query($query_del_record, $CA_database) or die(mysql_error());
$row_del_record = mysql_fetch_assoc($del_record);
$totalRows_del_record = mysql_num_rows($del_record);
?>
<?php require_once('../Connections/CA_database_connection.php'); ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<p><strong><font color="#006600" size="5" face="Arial, Helvetica, sans-serif">Delete
Confirmation</font><font color="#FF0000" size="5" face="Arial, Helvetica, sans-serif"><br>
</font><font color="#FF0000" face="Arial, Helvetica, sans-serif">WARNING!!
<br>
Clicking the Delete Button Below will Permanently Delete This record.</font></strong></p>
<p><font color="#003300" size="5" face="Arial, Helvetica, sans-serif"><font size="3"><a href="admin_control.php">CONTROL</a>
| <a href="admin_add.php">ADD</a> | <a href="view.php">VIEW</a> | <a href="admin_update1.php">UPDATE</a>
| DELETE | <a href="../index.html" target="_blank">PUBLIC</a></font></font>
</p>
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="25%" rowspan="5"><div align="center"><img src="<?php echo $row_del_record['prod_pic']; ?>" alt="" name="del_pic"></div></td>
<td width="15%">Product Number:</td>
<td width="60%"><?php echo $row_del_record['prod_num']; ?></td>
</tr>
<tr>
<td>Product Name</td>
<td><?php echo $row_del_record['prod_name']; ?></td>
</tr>
<tr>
<td>Designer</td>
<td><?php echo $row_del_record['designer']; ?></td>
</tr>
<tr>
<td>Category</td>
<td><?php echo $row_del_record['prod_cat']; ?></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="3">
<div align="center">
<input type="submit" name="Submit" value="Delete">
</div></td>
</tr>
</table>
</form>
<p> </p>
</div>
</body>
</html>
<?php
mysql_free_result($del_record);
?>
Thanks Heaps for any help
The Bird from Down Under- Bigbird 3156
Programmer?? - I thought the option was pretender not programmer!!