I have a form on the bottom of my webpage, when i submit the form and the page refreshes i would like for the page to automatticly be positioned at the bottom of the page so i see the form again. Is it poss开发者_JAVA技巧ible to achieve this without using any javascript, only with php.
Yes. You can do this using the name attribute of a link.
At the bottom of your page have this code:
<!-- The page with the form (script.php) -->
<?php
//Other page content
?>
<a name="bottomOFThePage"></a>
<?php
//Your form
?>
<!--
PHP page that handles the form submit
Use the header code from netcoder's answer below
-->
<?php
//Process your form
header('Location: script.php#bottomOfPage');
?>
Redirect after you submit the form to http://yoururl.com/script.php#bottomOfThePage
The best way to do this without JavaScript is to put an anchor tag at the bottom of your page:
<a name="bottomOfPage"></a>
Then, redirect the user to the bottom of the page (or submit a form to):
<?php
header('Location: script.php#bottomOfPage');
exit;
精彩评论