# php redirection

**URL:** <https://forum.phpvms.net/t/php-redirection/3586>\
**Category:** phpVMS Legacy Support (v2/v5)\
**Created:** [October 29, 2010, 6:40pm UTC](https://forum.phpvms.net/t/php-redirection/3586 "2010-10-29T18:40:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [October 29, 2010, 6:40pm UTC](https://forum.phpvms.net/t/php-redirection/3586/1 "2010-10-29T18:40:40Z")

</div>

HI is there a way to redirect to the requested page if members are not logged in?

For example, someone tries to reach a page that requires them to be logged in so they are firstly directed to the login page then after successfully logging in they are taken to their initial requested page.

---

<div class="post-metadata">

**Author:** ![Jon](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@Jon](https://forum.phpvms.net/u/Jon)\
**Post date:** [October 30, 2010, 8:58am UTC](https://forum.phpvms.net/t/php-redirection/3586/2 "2010-10-30T08:58:44Z")

</div>

I Don’t know if it would work but maybe an if statement:

```
<?php 
 /* 
 Quick example of how to see if they're logged in or not
 Only show this login form if they're logged in */
 if(Auth::LoggedIn() == false)
 { ?>

<a href="http://www.domain.com/index.php/login">
Please Login To View This Page!

<?php
{$this->show('login_form.tpl'); }
?>

</a>

```

Was just a thought but probably won’t work lol

---

<div class="post-metadata">

**Author:** ![simpilot](https://forum.phpvms.net/user_avatar/forum.phpvms.net/simpilot/32/26_2.png) [@simpilot](https://forum.phpvms.net/u/simpilot)\
**Post date:** [October 30, 2010, 11:01am UTC](https://forum.phpvms.net/t/php-redirection/3586/3 "2010-10-30T11:01:39Z")

</div>

To redirect back to the index page you can use;

```
header('Location: '.url('/'));

```

You can redirect to a certain page by adding the module in the url command. For example if you want to redirect to the pilots list;

```
header('Location: '.url('/pilots'));

```

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [October 30, 2010, 11:40am UTC](https://forum.phpvms.net/t/php-redirection/3586/4 "2010-10-30T11:40:17Z")

</div>

Is it possible to pass the initial requested page as a variable so once they logged it it would take them to that page?
