Jump to content

alternative to header()?


fezzik

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

Link to comment
https://forums.phpfreaks.com/topic/24059-alternative-to-header/
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]
Link to comment
https://forums.phpfreaks.com/topic/24059-alternative-to-header/#findComment-109402
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
Link to comment
https://forums.phpfreaks.com/topic/24059-alternative-to-header/#findComment-109676
Share on other sites

Archived

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

×
×
  • Create New...

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.