Hello,
Can anyone help me with this? I'm trying to update a record in my database, but when i click submit, the database does not update.
Here is the code:
<p>
<?
require('../Templates/config.inc');
// connect to database
$cid = mysql_connect($host,$usr,$passwd);
if (!$cid) {
echo("ERROR: " . mysql_error() . "\n");
}
// processed when form is submitted back onto itself
if ($REQUEST_METHOD=="POST") {
// make sure all fields have something in them
while(list($key, $value) = each($HTTP_POST_VARS)) {
if ($value == "") {
$value = "*";
}
$$key = $value;
}
// setup SQL statement
$SQL = " UPDATE simplebit_content SET";
$SQL = $SQL . " content_about = '$content_about' ";
$SQL = $SQL . " WHERE id = 1 ";
// execute SQL statement
$result = mysql_db_query($db,"$SQL",$cid);
// check for errors
if (!$result) {
echo("ERROR: " . mysql_error() . "\n$SQL\n");
} else {
// confirmation string to appear at the bottom of the page
$uconfirm = "<p span='submenu'>The ABOUT page has been updated.</p>";
}
} else {
// setup SQL statement to retrieve subscriber that we want to edit
$SQL = " SELECT * FROM simplebit_content";
$SQL = $SQL . " WHERE id = 1 ";
// execute SQL statement
$ret = mysql_db_query($db,$SQL,$cid);
//retrieve values
$row = mysql_fetch_array($ret);
$content_about = $row["content_about"];
}
?>
</p>
<p><form name="form1" method="post" action="about.php">
<input type="hidden" name=id value="<?echo$id;?>">
<table width="100%" border="0" cellspacing="1" cellpadding="5">
<tr id=dark>
<td class="submenu">Edit <span class="submenu2"><font size="2"><strong>About</strong></font></span>
Text:</td>
</tr>
<tr>
<td> <textarea name="textfield" cols="100" rows="15" class="submenu"><?echo$content_about;?></textarea></td>
</tr>
<tr>
<td> <input name="Submit" type="submit" class="submenu2" value="Edit Client">
</td>
</tr>
<?
if ($REQUEST_METHOD=="POST") {
echo ("$uconfirm\n");
}
?>
</table>
</form></p>