I don't quite understand your problem,  it might help to see some of the
php or form html. It might also help if I explain how I usually handle updates.

I have a single php page with the form on it which is also the target
of the form.

Typically users get to the form via a link which includes the "id" on the
url (i.e. passed as a GET variable).  The php picks up this id and uses
it to query the database to get the current data.  Then the form is 
presented with the form values set to the current values and the "id"
included as a hidden field.  The user makes a change and presses a submit 
button with the name "update" (<INPUT TYPE="SUBMIT" NAME="update">)

The php checks to see if "update" is set (isset($update)).  If it is
it uses the form values to update the database before it goes to search
for the current values. Then it just continues as normal retrieving the
database (new) values and printing out the form.  i.e. the logic is :

if (isset($update))
    update database for "id" record
    e.g. update mytable set myfield = '".$myfield."' where id = '".$id."'

select data for "id" record into myrow
e.g. select * from mytable where id = '".$id."'

print form including data
    print '
   MY FIELD : <INPUT TYPE="TEXT" NAME="myfield" VALUE="'.$myrow['myfield'].'">
   <INPUT TYPE="SUBMIT" NAME="update">

For the user this means they always have visual confirmation that their
changes have gone to the database after pressing SUBMIT.  If they're
happy they have a link to go wherever they want to next.  If they're
not happy they can correct the data and submit again.

Could you be getting problems because there is confusion between your
hidden "id" and the "id" on the url?  The ACTION="'.$SCRIPT_NAME.'" 
should sort that out since it will remove anything passed on the url
when the form is submitted.

Or perhaps you have set the values in the form to php variables with
the same name as the form variables e.g.

print '<INPUT TYPE="TEXT" NAME="myfield" VALUE="'.$myfield.'">

If this is the case, then the form will always come back with the last
entered details and not blank details since $myfield is continually
being set to the value of the HTML input variable myfield.

Sorry I can't help more without getting a better idea of what you
are trying to achieve!


Rodrigo Peres wrote:
> Hi list,
> I have PHP code to insert the result of a form into mysql. When I nedd to
> made an update, I pass an "id" in the url and use it to make the update
> query. The problem is after I click in the update button (input submit) my
> page refresh and came back in the same state, to see the changes I need to
> type in the url again with the parameter?? why?? There's a way to avoid this
> and get a new blank form page after the update?
> ps: I've stored the "id" in a input type hidden, so I could click the button
> and still have the id
> Thank's in advance
> Rodrigo Peres
> --

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to