hi i am learning how to make a user login script in php. And I wrote a html page and 2 php pages. Visitors will access through html page using their password and username... And when click on submit then the second page will process it .... I make one like this ...

process.php page

$username=$_POST['username'];
$password=$_POST['password'];
if ($username=="some" && $password=="some"){
header('Location: ' . mypage.php);
}else
header('Location: ' . incorrectpage.php);

Please let me know is it ok ? or any change ??? Please help me ...

Well the only glaring issue I see is, you lack the ability to tell if the user is logged in once they leave the page.

<?php
//process.php
session_start();

$username=$_POST['username'];
$password=$_POST['password'];

if ($username=="some" && $password=="some")
{
  //Username & Password match
  //Set a session value so we know they were logged in successfully
  $_SESSION['loggedIn'] = time();
  //Redirect to the member only page
  header( 'Location: mypage.php' );
}
else
{
  //user failed to login
  header( 'Location: incorrectpage.php)' ;
}
<?php
//mypage.php
session_start();

if( !empty( $_SESSION['loggedIn'] ) )
{
  echo 'Member Content';
}
else
{
  //User is not logged in, but tried to direct link
  header( 'Location: incorrectpage.php' );
}

This is just a rough example of how to work with sessions.
http://us2.php.net/session Other then that you seem to have the basic concept.

This article has been dead for over six months. Start a new discussion instead.