Is this really that hard??? I'm at wits end here. I have coded and coded, wiped it all out and coded some more. I'm not hitting on any combination that will work. Can someone please assist me in this to save my sanity?
Very simple....I have a page displaying information from my retrieved record. I want to update the info. I click submit...it updates the record. BUT....the page goes back to displaying the old data. I have to do a manual refresh of the screen to get it to display the new data. It should be displaying the changed information.
How in the world do I get this to work properly?
Here's my very simple plain vanilla code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Update Test Page</title>
<?php
mysql_connect("localhost", "<id>", "<pw>") or die("Failure to communicate with database");
mysql_select_db("<db>");
$query = "SELECT name from <table> where sname='Bob'";
$result = mysql_query($query);
$parr=mysql_fetch_array($result);
?>
</head>
<body bgcolor="#ffffff">
<form name="form" method="POST" action="<?php echo $SERVER['PHP_SELF']; ?>">
<!--
<form name="form" method="POST">
-->
<table width="616" border="1" cellspacing="2" cellpadding="0">
<tr>
<td width="120"></td>
<td width="120"></td>
<td width="120"><input type="text" name="tst" value="<?php echo $parr['name'] ?>"></td>
<td width="120"></td>
<td width="120"></td>
</tr>
<tr>
<td width="120"></td>
<td width="120"><input type="submit" name="Test1"></td>
<td width="120"></td>
<td width="120"><input type="reset" name="Test2"></td>
<td width="120"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
if($POST['Test1']) {
$query = "UPDATE <table> set name='$tst' where sname='Bob'";
$result = mysql_query($query);
echo "It Worked";
} elseif($_POST['Test2']) {
echo "you have chosen to reset the form";
}
?>
<?php if (false) { ?><!-- Mock Content
"Updt/screenname" html {Label}
"Updt/st" text {}
--><?php } ?>