How do I link Two pages with PHP

I am making a website and in my website i have the very firstpage which is just plainly a login page. Now all i have to do is validate users loging using PHP but then i am stuck on how to link the second page to the the Login page so when the user logs in he is redirected to that page. I need Help on that end

Thanks

Answers


Upon successfully logging in, you will likely want to redirect to the second page using a header redirection.

header( "Location: page2.php" );
exit;

if($login == true){
header('location:http://yoursite.com/newindex.php');
}

You have 2-3 ways to do it

IMPORTANT: You must to check login status in all.php files.

1. redirect after login

You'll send header after login, but dont forget about ob_start()

<?php
ob_start();
...
if($login) { // your condition
 header('Location: page2.php');
} 
2. if/else inclusion variant
<?php
if(!$loged) {
//show login page
} else {
 include('page2.php'); // or do smth other
} 
3. check login in every page

include in every page 'login.php' same as if/else variant.

<?php //page2.php
if(!$logged) {
 include 'login.php'; 
} else {
....
}

Need Your Help

Place a word in a 2d array

java arrays algorithm

is there a way to place a word in a 2d array in a specific position? For example,i want to give the word, choose vertical or horizontal and the position ((3,3) or (3,4) or (5,6) etc) and the word w...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.