FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


username admin link





hcaracol
what i want it's when i type admin goes to some link(index1.php) and when i type like guest goes to index2.php, how can i do this??

Thanks,
rickylau
(I guess you are asking something that have answer like this...)
Assuming you want to redirect the page according to a variable (Any variable, a $_GET parameter, a $_SESSION variable, and so on), just do something like this
Code:
if ($who == 'admin')
  header ('Location: admin_page.php');
else
  header ('Location: guest_page.php');
or in an even simpler form:
Code:
header ('Location: '.($who == 'admin' ? 'admin_page.php' : 'guest_page.php'));


Code:
$who == 'admin'
This expression compares $who with string 'admin'
Code:
header ('Location: '.$page_name);
And this statement adds a header telling the browser to change location to $page_name
jmraker
To prevent anyone from using the admin page you should put a session and put the login info there.

something like
Code:
<?php

... session_start() ...

if(!isset($_SESSION['user_type'])){
    header('Location: /login.php');
    exit();
}
elseif($_SESSION['user_type'] != 'admin'){  // They are logged in but not an admin, redirect to the guest page
    header('Location: /guest.php');
    exit();
}

.... admin stuff ....
?>
Related topics
Private Page
How do you access phpmyadmin?
Just uploaded. Shouldn't be jibberish.
FrontPage Admin
[TuT]JOOMLA Installation Guide (Less Easy Way)
Updating phpbb
Login Scripts
Aha! Now I know why Bondings hates...
password?
phpBB Services
4Images Install
Opening port 8080
Nuke Help
help with random
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.