[PHP] changing form based on variable

2010-07-20 Thread David Mehler
Hello,
I've got a form, it's sticky, and it can either display on an insert
or update. Depending on whether i'm wanting to do an insert or update
the area the form gets it's input changes.
So, i've got a name field, if it's set to insert, not sure how to
differentiate between the two actions, name gets it's input from the
value of $_POST['name'] since it's sticky. If it's set to update that
name value is filled in by the name field output in a database. Also,
if insert the button for sending the form is called add if update
it's called update I'd like to know how to pull this off, because in
both cases the form entry fields are the same, i don't want to have to
write two forms when one should work.
Thanks.
Dave.

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



Re: [PHP] changing form based on variable

2010-07-20 Thread Phpster


On Jul 20, 2010, at 13:28, David Mehler dave.meh...@gmail.com wrote:

 Hello,
 I've got a form, it's sticky, and it can either display on an insert
 or update. Depending on whether i'm wanting to do an insert or update
 the area the form gets it's input changes.
 So, i've got a name field, if it's set to insert, not sure how to
 differentiate between the two actions, name gets it's input from the
 value of $_POST['name'] since it's sticky. If it's set to update that
 name value is filled in by the name field output in a database. Also,
 if insert the button for sending the form is called add if update
 it's called update I'd like to know how to pull this off, because in
 both cases the form entry fields are the same, i don't want to have to
 write two forms when one should work.
 Thanks.
 Dave.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


Simple, I assume you have an id for the record on update, so test for that and 
just adjust the value of the button.

$btnValue = 'Submit';
If(isset($id)){
  $btnValue ='Update';
}

Bastien

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