|
Posted by cover on 01/15/06 06:34
I'm trying to put together a system that upgrades records in a
database and apparently have run into a bit of a glitch. I think the
problem is with the $HTTP_POST_VARS portion of the code. Is there
some variable that has to be set for this to work properly or what?
Ideas anyone? TIA
The Input form: (1 of 3 forms)
<html>
<head>
<title>SystemsDoc Update</title>
</head>
<body bgcolor="white">
<form method="POST" action="sysdocupdate.php">
<table>
<col span="1" align="right">
<tr>
<td><font color="blue">UID to Update:</font></td>
<td><input type="text" name="UID" size=100></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
This one populates the fields for updating:
<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
require_once("config.php");
$db1=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("sysops");
$query="SELECT * FROM systemsdoc WHERE UID =
\"".$formVars["UID"]."\"";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$formVars = array();
$formVars["manu"]=$row["manu"];
$formVars["model"]=$row["model"];
$formVars["addr"]=$row["addr"];
$formVars["zip"]=$row["zip"];
$formVars["phone"]=$row["phone"];
$formVars["deploy_date"]=$row["deploy_date"];
$formVars["sernum"]=$row["sernum"];
$formVars["assetnum"]=$row["assetnum"];
$formVars["machname"]=$row["machname"];
$formVars["sysversion"]=$row["sysversion"];
$formVars["UID"]=$row["UID"];
mysql_close($db1);
?>
<html>
<head>
<title>SystemsDoc Update</title>
</head>
<body bgcolor="white">
<form method="post" action="postupdate.php">
<table>
<col span="1" align="right">
<tr>
<td><font color="blue">Manufacturer:</font></td>
<td><input type="text" name="manu"
value="<? echo $formVars["manu"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Model:</font></td>
<td><input type="text" name="model"
value="<? echo $formVars["model"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Address:</font></td>
<td><input type="text" name="addr"
value="<? echo $formVars["addr"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Zip:</font></td>
<td><input type="text" name="zip"
value="<? echo $formVars["zip"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Phone:</font></td>
<td><input type="text" name="phone"
value="<? echo $formVars["phone"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Deployment Date:</font></td>
<td><input type="text" name="deploy_date"
value="<? echo $formVars["deploy_date"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Serial Number:</font></td>
<td><input type="text" name="sernum"
value="<? echo $formVars["sernum"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Asset Number:</font></td>
<td><input type="text" name="assetnum"
value="<? echo $formVars["assetnum"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">Machine Name:</font></td>
<td><input type="text" name="machname"
value="<? echo $formVars["machname"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">System Version:</font></td>
<td><input type="text" name="sysversion"
value="<? echo $formVars["sysversion"]; ?>" size=100></td>
</tr>
<tr>
<td><font color="blue">UID:</font></td>
<td><input type="text" name="UID"
value="<? echo $formVars["UID"]; ?>" size=100></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</body>
</html>
This one does the update:
<html>
<head>
<title>SystemsDoc Update</title>
</head>
<body bgcolor="white">
<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
require_once("config.php");
$db1=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("sysops");
echo "Record updated<br><a href=\"sysdocupdate.html\">click here</a>
to update another record<br>";
$query="UPDATE systemsdoc set ".
"manu= \"".$formVars["manu"]."\",".
"model= \"".$formVars["model"]."\",".
"addr= \"".$formVars["addr"]."\",".
"zip= \"".$formVars["zip"]."\",".
"phone= \"".$formVars["phone"]."\",".
"deploy_date= \"".$formVars["deploy_date"]."\",".
"sernum= \"".$formVars["sernum"]."\",".
"assetnum= \"".$formVars["assetnum"]."\",".
"machname= \"".$formVars["machname"]."\",".
"sysversion= \"".$formVars["sysversion"].
"\" WHERE UID = \"".$formVars["UID"]."\"";
mysql_query($query);
mysql_close($db1);
?>
</body>
</html>
Navigation:
[Reply to this message]
|