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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.