Re: Form help
| From: | Philip Olson | Date: | Thu, 22 Mar 2001 15:14:23 +0000 |
| Subject: | Re: Form help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45126@lists.php.net to get a copy of this message | ||
A common way is to add a check for the pressing of the submit button, so
assuming :
<input type="submit" name="submit" value="submit me!">
if ( isset($submit) ) {
// process form
} else {
echo 'oh dear, you did not use form.';
}
I usually use a hidden field instead as at times the submit button can be
"skipped" as the user presses enter vs. clicks the button, not sure what
browsers or setups allow this behavior but some do (maybe someone can
expand on this thought). So, try something like :
<input type="hidden" name="form_submitted" value="1">
if ( $form_submitted == true ) {
That should do the job. Also doing an is_array check somewhere in there
works if the form names are an array, like :
<input type="text" name="form[username]">
<input type="text" name="form[password]">
Other considerations apply but if $form is an array then most likely the
user used the form. So :
if ( is_array($form) ) {
Regards,
Philip Olson
http://www.cornado.com/
On Thu, 22 Mar 2001, Good Fella wrote:
> Hi All,
>
> I currently have a small problem with my PHP form. I have made two PHP
> files (application.php and process_application.php).
>
> On submitting the form, you then move to process_application.php. Any
> errors will force the form NOT to be submitted to me.
>
> However, how do I stop people from accessing process_application.php
> directly? You can still type in the URL of this address without filling in
> any details.
>
> Although it serves up an error, is there anyway I can prevent people from
> getting to this page unless they press "Submit" on the actual form on
> application.php?
>
> Thanks,
>
> SK
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.ë7ç
> 4ev#zmô„
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>