Go Back to Previous Page

前端 未结 11 699
悲哀的现实
悲哀的现实 2020-12-02 07:20

I am using a form to \"Rate\" a page. This form \"posts\" data to a php script elsewhere. I simply want to display a link after the form is processed which will bring the us

11条回答
  •  孤街浪徒
    2020-12-02 08:17

    You specifically asked for JS solutions, but in the event that someone visits your form with JS disabled a PHP backup is always nice:

    when the form loads grab the previous page address via something like $previous = $_SERVER['HTTP_REFERER']; and then set that as a in your form. When you process your form with the script you can grab that value and stick it in the header("Location:___") or stick the address directly into a link to send them back where they came from

    No JS, pretty simple, and you can structure it so that it's only handled if the client doesn't have JS enabled.

提交回复
热议问题