The registration form is not called up on all pages, so it became necessary to return exactly to the one from where you came ... But not on one, but on two pages, because when processing the form, a message is displayed, such as "you are successfully registered" on the 2nd page ... How to return to two (several) pages without specifying a specific address?
- For such purposes, the address from which it came is passed as an additional parameter. And after a successful registration / login, a redirect is made to the specified address. - metazet
|
3 answers
possible via javascript
function back(){ document.history.go(-2); } setTimeOut('back()',5000); |
In the registration form, make a +1 field
<input type="hidden" name="backurl" value="<?=$_SERVER['HTTP_REFERER']?>" /> in the message:
... ?><p>Вы успешно зарегистрировались!</p> <script type="text/javascript"> setTimeout(function(){ top.location.href='<? echo (!empty($_POST['backurl'])) ? $_POST['backurl'] : '/'; ?>'; }, 5000); </script> <? ... |
On a few, most likely, no way, so you can use
$_SERVER['HTTP_REFERER']
+
SUPERGLOBAL MASSIF $ _SERVER
Do not forget, the referee should be checked, and among other things - you need to save it, session, cookies - how to like it more.
UPD:
To come back...
<meta http-equiv="Refresh" content="секунды;URL="адрес"> - And if the user doesn’t call "registration", then how, for example, should Cookies be set so that when they leave the page they end? .. - Freeware
- Kill cookies / session if there was no transition to the page) - DemoriaN
- So I do not understand how to check the transition, if the transition will have another page, on which this cookie / session is needed? .. And they are not needed, if they left the page further, without registering ... That is, somewhere , before the end of the script of this page should they be turned off immediately? .. - Freeware
- The question was how to implement, and do not write me the code how it is done. The session can be updated until the user goes to the necessary page, though it is cumbersome ... It is simpler to announce the session with the value of the page address on each particular page. I just have a simple registration built, and the return is just on the index. If you do as you want, if the body is included in the
index.phpin the index header, declare the session if the address is not equal to, for example,index.php?i=register. Well, I think the idea brought it. - DemoriaN - and return this code to a person 1 page back and not 2) but basically nothing either))) it’s never too late to remember a session))) or a cookie ... - DemoriaN
|