Forum Moderators: coopster
<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="id" size=100></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
=========================================================
sysdocupdate.php
<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
require_once("config.php");
$db1=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("powerman_config");
$query="SELECT * FROM clients WHERE id = \"".$formVars["id"]."\"";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$formVars = array();
$formVars["Client"]=$row["Client"];
$formVars["id"]=$row["id"];
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">Client:</font></td>
<td>
<input type="text" name="Client"
value="<? echo $formVars["Client"]; ?>" size="100" ?>" size="100" ?>" </td>
</tr>
<tr>
<td><font color="blue">ID:</font></td>
<td>
<input type="text" name="id"
value="<? echo $formVars["id"]; ?>" size="100" ?>" size="100" ?>" </td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</body>
</html>
===============================================================
postupdate.php
<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("powerman_service");
echo "Record updated<br><a href=\"update.html\">click here</a> to update another record<br>";
$query="UPDATE clients set ".
"Client= \"".$formVars["Client"]."\",".
"\" WHERE id = \"".$formVars["id"]."\"";
mysql_query($query);
mysql_close($db1);
?>
</body>
</html>
Any help would be greatly appreciated.
<html>
<head>
<title>SystemsDoc Update</title>
</head>
<body bgcolor="white">
<?php
// Save form values to $formVars array
foreach($HTTP_POST_VARS as $varname => $value)
{
$formVars[$varname]=$value;
}
// Include database config file
require_once("config.php");
// Connect to mysql and select database
$db1 = mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("powerman_service");
// Run query, check for errors
$query = "UPDATE clients SET Client = '{$formVars["Client"]}' WHERE id = '{$formVars["id"]}'";
if (mysql_query($query) == FALSE)
{
echo "Database Error: " . mysql_error();
}
// Check for affected records
if (mysql_affected_rows() > 0)
{
echo "Record updated<br><a href=\"update.html\">click here</a> to update another record<br>";
}
else
{
echo "No records updated";
}
// Close database connection
mysql_close($db1);
?>
</body>
</html>