[PHP] New to PHP form attributes

2003-10-07 Thread Matthew Oatham
Hi,

I am new to PHP and am more used to JSP. My question is - if I submit a form 
to a php3 page using action==? PHP_SELF ?  for some processing all is 
well I can see that form data. After the processing the page is redisplayed 
- but the data originally sent persits (in the request) this can be a pain 
if the user was to hit the refresh button then the data is submitted to the 
server again and if for example the php page does an insert into a database 
then a new row would be created etc...

Is this normal behaviour of php and jsp ? I am not sure but I am noticing it 
now with php ? Should I be clearing the data from the request somehow after 
I have done my processing?

Thanks

Matt

_
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

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


Re: [PHP] New to PHP form attributes

2003-10-07 Thread Marek Kilimajer
You should use post method for forms that change state on the server, 
that way the user gets a warning. And you should redirect after 
processing the form to another page.

if($_GET['action']=='submit') {
INSERT INTO table VALUES (NULL, '$_GET[input]'
header('Location: ...');
} else {
form action=? PHP_SELF ??action=submit method=POST
input type=text name=input
/form
}
Matthew Oatham wrote:

Hi,

I am new to PHP and am more used to JSP. My question is - if I submit a 
form to a php3 page using action==? PHP_SELF ?  for some processing 
all is well I can see that form data. After the processing the page is 
redisplayed - but the data originally sent persits (in the request) this 
can be a pain if the user was to hit the refresh button then the data is 
submitted to the server again and if for example the php page does an 
insert into a database then a new row would be created etc...

Is this normal behaviour of php and jsp ? I am not sure but I am 
noticing it now with php ? Should I be clearing the data from the 
request somehow after I have done my processing?

Thanks

Matt

_
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

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


Re: [PHP] New to PHP form attributes

2003-10-07 Thread Chris Shiflett
--- Matthew Oatham [EMAIL PROTECTED] wrote:
 I am new to PHP and am more used to JSP. My question is - if I
 submit a form to a php3 page using action==? PHP_SELF ?  for
 some processing all is well I can see that form data. After the
 processing the page is redisplayed - but the data originally sent
 persits (in the request)

You need to be more specific here. After the processing, the page is
redisplayed? Does this mean you simply generate the appropriate output (using
include() perhaps), redirect the user somewhere, the user clicks reload, or
what? I would assume the first, but your problem sounds like you are doing
something else.

 if the user was to hit the refresh button then the data is submitted
 to the server again and if for example the php page does an insert
 into a database then a new row would be created etc...

Now this question comes up a lot. There are many ways around it, and you will
probably find more than I can mention by searching the archives. In fact, I'll
only give you one suggestion now.

If you form, form.php, submits to process.php, you can process the form with
process.php and then include a Location header that redirects the user back to
form.php:

header('Location: http://yoursite.org/form.php');

This type of redirection is transparent to history mechanisms, so even clicking
back in the browser won't cause the intermediate page to be displayed. A user
who clicks reload will be reloading the form.php page which only generates the
HTML form.

I recommend searching the archives for other alternatives and choose whichever
one seems best to you.

 Is this normal behaviour of php and jsp?

Yes.

 I am not sure but I am noticing it now with php?

Yes, it seems you are noticing it now, thus your question.

Hope that helps.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

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