Theora Posted August 18, 2006 Share Posted August 18, 2006 I'm trying to allow someone to update a record (using the Update Record server behavior in Dreamweaver 8 ) and upon completion redirect to the page "admin.php". For some reason when the submit button is pressed the page simply reloads and the fields contain the original information with all changes lost. Any idea what's going wrong? Thanks... following is the code.[code]<?php require_once('Connections/content.php'); ?><?phpfunction 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"] == "updating")) { $updateSQL = sprintf("UPDATE content SET primary_con=%s, pagecontent_con=%s, updated_con=%s WHERE pagename_con=%s", GetSQLValueString($_POST['key'], "int"), GetSQLValueString($_POST['textarea'], "text"), GetSQLValueString($_POST['updated'], "date"), GetSQLValueString($_POST['pagename'], "text")); mysql_select_db($database_content, $content); $Result1 = mysql_query($updateSQL, $content) or die(mysql_error()); $updateGoTo = "admin.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo));}$colname_rsEdit = "-1";if (isset($_GET['recordID'])) { $colname_rsEdit = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);}mysql_select_db($database_content, $content);$query_rsEdit = sprintf("SELECT * FROM content WHERE pagename_con = '%s'", $colname_rsEdit);$rsEdit = mysql_query($query_rsEdit, $content) or die(mysql_error());$row_rsEdit = mysql_fetch_assoc($rsEdit);$totalRows_rsEdit = mysql_num_rows($rsEdit);?><!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=ISO-8859-1" /><title>Untitled Document</title></head><body><form id="updating" name="updating" method="POST" action="<?php echo $editFormAction; ?>"> <table width="500" border="0" align="center" cellpadding="15" cellspacing="0"> <tr> <td><input name="key" type="hidden" id="key" value="<?php echo $row_rsEdit['primary_con']; ?>" /> <input name="pagename" type="hidden" id="pagename" value="<?php echo $row_rsEdit['pagename_con']; ?>" /> Updating <?php echo ucfirst($row_rsEdit['pagename_con']); ?></td> </tr> <tr> <td><textarea name="textarea" cols="55" rows="20"><?php echo $row_rsEdit['pagecontent_con']; ?></textarea></td> </tr> <tr> <td><input name="updated" type="hidden" id="updated" value="<?php echo $row_rsEdit['updated_con']; ?>" /> <input name="Update" type="submit" id="Update" value="Submit" /></td> </tr> </table> <input type="hidden" name="MM_update" value="updating"></form></body></html><?phpmysql_free_result($rsEdit);?>[/code] Quote Link to comment Share on other sites More sharing options...
Carter7 Posted August 26, 2006 Share Posted August 26, 2006 I had the same problem with a script i wrote myself, i do not quite know how i over come it, though it still updates it in the database it just does not show the updated information, this could be because of where you update process is. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 26, 2006 Share Posted August 26, 2006 [code]if (isset($_GET['recordID'])) {[/code]I don't see anywhere in your code where recordID is passed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.