Jump to content

Archived

This topic is now archived and is closed to further replies.

fezzik

alternative to header()?

Recommended Posts

Is there an alternative command to use that will move you to a specific section of a page? I don't want to refresh the page using header() but would like to move the user to a specified location on the page. Basically I have a large form. When you encounter validation errors after submission I want to 'jump' the user to the specific section of the form where the error occured.

Cheers,

Fezzik

Share this post


Link to post
Share on other sites
You could use page anchors and redirect to them based on the errors.

[code]
<!-- Do some fancy javascript to call the anchor instead of making them click on it -->
<a href="#anchor_name">Jump me to some place in the code</a>

<a name="anchor_name">Some place in the code</a>
[/code]

Share this post


Link to post
Share on other sites
Thanks for the responses! I was thinking javascript was the best route to take too. I just wanted to see if it could be easily accomplished with php. I did create a method that allows this functionality with php. I created session variables to hold the values of the form variables that were a result of the form submission. Once the validation encounters an error I redirect the user with the header() command but append the appropriate page link to the end of the url. (i.e. header(somewebpage.php#contactInfo)) This will redirect the user to the location of the error. Although the page is refreshed using the header() command all the user's form input is still displayed because it was preserved using session variables.

Best,

Fezzik

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.