# Headers for variable redirection

**URL:** <https://forum.kirupa.com/t/headers-for-variable-redirection/78353>\
**Category:** programming\
**Created:** [February 3, 2005, 7:43pm UTC](https://forum.kirupa.com/t/headers-for-variable-redirection/78353 "2005-02-03T19:43:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wbarrett26](https://avatars.discourse-cdn.com/v4/letter/w/e9a140/32.png) [@wbarrett26](https://forum.kirupa.com/u/wbarrett26)\
**Post date:** [February 3, 2005, 7:43pm UTC](https://forum.kirupa.com/t/headers-for-variable-redirection/78353/1 "2005-02-03T19:43:30Z")

</div>

I have a quesiton about how to use Headers to redirect to a welcome page based on which username was entered.

I have a basic login page that initates a session. An included file handles user validation and all header info. First the username and password are checked against a database:

…$user=$\_POST[‘user’];  
$pass=$\_POST[‘pass’];…

Once validated the script checks if the person is “logged in” and then redirects them

\<?php …

if ($user=“user1”){  
header(“Location: [http://website.com/welcomepage1.php](http://website.com/welcomepage1.php)”);  
}else if ($user=“user2”){  
header(“Location: [http://website.com/welcomepage2.php](http://website.com/welcomepage2.php)”);  
}else{  
header(“Location: [http://website.com/welcomegeneric.php](http://website.com/welcomegeneric.php)”);  
}  
… ?\>  
I know this is not coded well but I am still learning. I have tried several ways of variable redirection but with no avail. Are there any suggestions? If this method seems wrong maybe I can have a the different web pages in the database and the header calls a variable through a MySQL query based on the entered username. Any advice is appreciated.  
Thanks in advance.
