0

Hi all

I have a website that has a contact form in the footer of every page. When someone sumbits their details I do a check to see if the fields are filled in correctly. If the fields aren't filled in correctly I display an error just above the form.

The problem is that when the page loads after submit I need it to jump to the bottom of the page. I've put the following code just above the contact form:
<code=html><a name="contact"></a></code>

And I'm trying to use the following php code to jump to the bottom of the page:
<code=php>header("Location: ".$_SERVER."#contact");</code>

The problem is that #contact isn't being included in the redirect. How do I include it?

4
Contributors
5
Replies
20
Views
6 Years
Discussion Span
Last Post by Venom Rush
0

you could use javascript instead of the header()-function, that would we what i would use:

<script>document.location.href = "index.php#contact";</script>

that refreshes the page and scrolls down to the #contact

0

you could use javascript instead of the header()-function, that would we what i would use:

<script>document.location.href = "index.php#contact";</script>

that refreshes the page and scrolls down to the #contact

Thanks for your response Agarsia. I'm hoping for a php solution in order to avoid a situation where someone doesn't have javascript enabled. I know very few will have it turned off but I like having a solution that's 100% guaranteed.

Edited by Venom Rush: n/a

0

Do your checking in the same script as the form display. Set your form action to "myformscript.php#contact" and relocate the user only after the form has successfully been submitted.

0

thinking out loud, whack in a ? mark like so:

header("Location: ".$_SERVER['PHP_SELF']."?#contact");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.