473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Updating Records

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>
Jan 15 '06 #1
1 1490
cover said the following on 15/01/2006 04: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


<...SNIP CODE...>

$HTTP_POST_VARS has been superceded by $_POST since PHP 4.1.0.

Also worth mentioning that you should use mysql_real_escape_string() on
all user-entered string values used in a MySQL query, and explicitly
cast numeric types before using in the SQL query.

--
Oli
Jan 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
1
by: Chris Jackson | last post by:
I'm a novice Access user and am not sure how to solve the following problem. Any help with the following would be greatly appreciated! I have two tables with identical structures, the first holds...
0
by: | last post by:
I am updating MS access tables with data in an xml document. I create two dataset, one for existing data and one for new data. I fill the first dataset with the records from MS Access, the second...
1
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass...
4
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
1
by: davidgordon | last post by:
Hi, If I am updating a list of records for a user on an asp page, is there a way to hold the page updating, even if they refresh the page, until I have updated all the records. i.e. rather...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
2
by: Alexey.Murin | last post by:
The application we are developing uses MS Access 2003 database (with help of ADO). We have noticed that during massive records updating the size of the mdb file increases dramatically (from 3-4 to...
10
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
5
by: Bill Schanks | last post by:
I have a winform app (VB 2005) that allows users to export data to excel, make updates to the excel file and import the data from that Excel file and update the database. My question is: Is it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.