Jump to content


Photo

alternative to header()?


  • Please log in to reply
4 replies to this topic

#1 fezzik

fezzik
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 16 October 2006 - 04:58 AM

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



#2 fert

fert
  • Members
  • PipPipPip
  • Advanced Member
  • 1,114 posts

Posted 16 October 2006 - 05:14 AM

http://www.phpfreaks...edirect/532.php

Si hoc legere scis nimium eruditionis habes
Gentoo Linux 2007.0 Firefox 2

#3 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 16 October 2006 - 09:35 AM

You'll need Javascript to do the 'jumping'

#4 xsist10

xsist10
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 16 October 2006 - 09:39 AM

You could use page anchors and redirect to them based on the errors.

<!-- 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>

SA PHP Archives - www.phparchives.za.org

#5 fezzik

fezzik
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 16 October 2006 - 06:50 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users