bronzino
11-15-2010, 04:43 AM
I have a PHP page with a form. When the form is submitted using the post method, it updates my database and reloads itself with the submitted form data. The only problem I am having is that when it reloads, it doesn't check with the MySql database to show the updated information (the database does get updated though!). If I do a reload through my browser, it does display the updated info from my database.
I tried putting a refresh header statement at the end of my PHP function, but Firefox balks at that, stating that the redirect will not end (it loops). Also, it's been several days since I monkeyed with this, but IIRC, if I use refresh and get it to stop looping, my pure POST form data is lost. I'd like a function that just mimics a reload. Is there such a thing? All my Google searches yield is reliance on Refresh to do what I am trying to do.
I'm very new to this; perhaps the answer will be obvious to you guys.
Thanks in advance for any help. :)
Elizabeth
* Below is a shortened version of my PHP code + some of my form data
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if //(
(isset($_POST["MM_update1"]))
//&& ($_POST["MM_update1"] == "frm_fixed"))
{
$updateSQL = sprintf("UPDATE Photos SET Fixed=%s WHERE `Key`=%s",
GetSQLValueString($_POST['Fixed'], "text"),
GetSQLValueString($_POST['Key'], "int"));
mysql_select_db($database_CollectionLocal, $CollectionLocal);
$Result1 = mysql_query($updateSQL, $CollectionLocal) or die(mysql_error());
}
if //(
(isset($_POST["MM_update2"]))
//&& ($_POST["MM_update2"] == "frm_fixed"))
{
$updateSQL = sprintf("UPDATE Photos SET `150`=%s WHERE `Key`=%s",
GetSQLValueString($_POST['150'], "text"),
GetSQLValueString($_POST['Key'], "int"));
mysql_select_db($database_CollectionLocal, $CollectionLocal);
$Result1 = mysql_query($updateSQL, $CollectionLocal) or die(mysql_error());
}
?>
<form name="frm_fixed" action="<?php echo $editFormAction; ?>" method="post">
<table border="1">
<tr>
<td>FilePath:</td>
<td>../<?php echo $row_Recordset2['ID']?>/<?php echo $_POST['Basename']; ?>_fixed.<?php echo $_POST['Extension']; ?><input name="Key" type="hidden" value="<?php echo $row_Recordset2['Key']?>"/></td>
</tr>
<tr>
<td>Width:</td>
<td><?php
list($fixedwidth, $fixedheight, $fixedtype, $fixedattr) = getimagesize("../".$row_Recordset2['ID']."/".$_POST['Basename']."_fixed.".$_POST['Extension']);
echo $fixedwidth;
?></td>
</tr>
<td>In Database?</td>
<td>
<?php if ($row_Recordset1['Fixed'] == $_POST['Basename']."_fixed.".$_POST['Extension'])
echo "File with Matching Name in Database";
else echo "No File with that Name in Database"; ?>
</td>
</tr>
<tr>
<td>Add to Database: </td>
<td><input name="150" type="text" />
<input name="MM_update1" type="submit" id="MM_update1" value="Add Fixed File" /><input name="MM_update2" type="submit" id="MM_update2" value="Add 150 size File" /></td>
</tr>
<tr>
<td> </td>
<td>Upload file (see local_photo_upload) & make diff sizes (see altsizes file)<input name="Add_File" type="submit" value="Add File" /></td>
</tr>
</table></form>
I tried putting a refresh header statement at the end of my PHP function, but Firefox balks at that, stating that the redirect will not end (it loops). Also, it's been several days since I monkeyed with this, but IIRC, if I use refresh and get it to stop looping, my pure POST form data is lost. I'd like a function that just mimics a reload. Is there such a thing? All my Google searches yield is reliance on Refresh to do what I am trying to do.
I'm very new to this; perhaps the answer will be obvious to you guys.
Thanks in advance for any help. :)
Elizabeth
* Below is a shortened version of my PHP code + some of my form data
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if //(
(isset($_POST["MM_update1"]))
//&& ($_POST["MM_update1"] == "frm_fixed"))
{
$updateSQL = sprintf("UPDATE Photos SET Fixed=%s WHERE `Key`=%s",
GetSQLValueString($_POST['Fixed'], "text"),
GetSQLValueString($_POST['Key'], "int"));
mysql_select_db($database_CollectionLocal, $CollectionLocal);
$Result1 = mysql_query($updateSQL, $CollectionLocal) or die(mysql_error());
}
if //(
(isset($_POST["MM_update2"]))
//&& ($_POST["MM_update2"] == "frm_fixed"))
{
$updateSQL = sprintf("UPDATE Photos SET `150`=%s WHERE `Key`=%s",
GetSQLValueString($_POST['150'], "text"),
GetSQLValueString($_POST['Key'], "int"));
mysql_select_db($database_CollectionLocal, $CollectionLocal);
$Result1 = mysql_query($updateSQL, $CollectionLocal) or die(mysql_error());
}
?>
<form name="frm_fixed" action="<?php echo $editFormAction; ?>" method="post">
<table border="1">
<tr>
<td>FilePath:</td>
<td>../<?php echo $row_Recordset2['ID']?>/<?php echo $_POST['Basename']; ?>_fixed.<?php echo $_POST['Extension']; ?><input name="Key" type="hidden" value="<?php echo $row_Recordset2['Key']?>"/></td>
</tr>
<tr>
<td>Width:</td>
<td><?php
list($fixedwidth, $fixedheight, $fixedtype, $fixedattr) = getimagesize("../".$row_Recordset2['ID']."/".$_POST['Basename']."_fixed.".$_POST['Extension']);
echo $fixedwidth;
?></td>
</tr>
<td>In Database?</td>
<td>
<?php if ($row_Recordset1['Fixed'] == $_POST['Basename']."_fixed.".$_POST['Extension'])
echo "File with Matching Name in Database";
else echo "No File with that Name in Database"; ?>
</td>
</tr>
<tr>
<td>Add to Database: </td>
<td><input name="150" type="text" />
<input name="MM_update1" type="submit" id="MM_update1" value="Add Fixed File" /><input name="MM_update2" type="submit" id="MM_update2" value="Add 150 size File" /></td>
</tr>
<tr>
<td> </td>
<td>Upload file (see local_photo_upload) & make diff sizes (see altsizes file)<input name="Add_File" type="submit" value="Add File" /></td>
</tr>
</table></form>