Re: Question before I end up writing alot of extra code...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jul 7, 2008, at 3:36 PM, Wolf wrote:

---- Jason Pruim <japruim@xxxxxxxxxx> wrote:
Hi everyone!

So it's been a nice long weekend, I come in to work and try and mess
with a project that I'm working on to get some new features added. All was going well until I realized that now my application is breaking...

Here's the details...

PHP 5.2
MySQL 5.2

I store the info in the database which is submitted from a HTML form..
Some of it text boxes, some check boxes, some radio buttons... I
$_POST the info from the form into the processing script.

The problem I'm running into though, is when a value has not changed
it doesn't get $_POSTed back and my update script erases the info in
the database... I'm trying to avoid using $_GET since it can be quite
a few variables.

Is there anyway I can do it without comparing the original field to
what I am displaying?

Gone for a weekend and we have to retrain, at least I'm not the only one... ;)

POSTed variables are ALWAYS posted back, changed or not.

More then likely you are forgetting a piece of code, but since you didn't post the offending code, I can't point out where you forgot the $ or to restate a variable. :-P

Here is a VERY simplified test :)
MAIN PAGE:
<?PHP
if($row['Tab'] == "done"){
	$Tchecked1 = "CHECKED";
	$Tchecked2 = NULL;
}else{
	$Tchecked1 = NULL;
	$Tchecked2 = "CHECKED";
}

echo"
<fieldset>Tab<BR>
<input type="radio" name="rdoTab" value="done" $Tchecked1>Done <BR>
<input type="radio" name="rdoTab" value="on" $Tchecked2>Not Done<BR>
</fieldset>";
?>
PROCESSING:
<?PHP
				$tab = $_POST['rdoTab'];
				$record = $_POST['txtRecord'];
$updateQuery = "UPDATE `current` SET Tab='$tab' WHERE Record='$record'";
				
mysqli_real_query($link, $updateQuery);	

?>

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux