[thelist] PHP Jump to Anchor Tags?

Ron Dorman rwd at csi1st.net
Thu Oct 11 13:21:14 CDT 2001


Simon Coggins wrote:

> So PHP is validating the form info then you want to either display a
> 'that worked' page or a 'that didn't work try again' page. I can think of
> two approaches:
>
> 1. Make the action of the form point to some intermediate script that does
> the validation then do a php redirect to either the results page or the
> first page with the anchor included.
>
> 2. Make the whole form one .php file and decide what to display based on
> which variables are defined (e.g. $HTTP_POST_VARS["submit"] if the submit
> button has is named submit). Make the action of the form point to the
> anchor:
>
> <form action="<?php=$PHP_SELF?>#anchor" method="post">
>
> if the validation is successful then the #anchor won't be used, otherwise
> it will.
>
> I prefer (2), because option (1) will disable the back button.
>
> I hope this is clear. If not ask and I'll try to be more eloquent.

I prefer 2 also, and am currently close to that.  Current form has:

<form method="post" name="nm" title="pt" action="<?php echo $PHP_SELF ?>">

so I added my anchor name to the end and it works just fine.  First entry into
page displays the top.  Errors after submit positions at the anchor.  Valid info
goes on to the next page.

Thanks.





More information about the thelist mailing list