Well I think I am getting it. But I am having issues with the login, check_login pages.
Do I have to set up the login info on the check_login.php? I have it all in the config file.
Here is what I have.
login page
[php] <?php
$login_form = <<<EOD
Username:
Password:
EOD;
$msg = $_GET['msg']; //GET the message
if($msg!='') echo '
'.$msg.'
'; //If message is set echo it
echo "
Please enter your Login Information
";
echo $login_form;
?>[/php]
check_login
[php]<?php
define(DOC_ROOT,dirname(FILE)); // To properly get the config.php file
$username = $_POST[‘username’]; //Set UserName
$password = $_POST[‘password’]; //Set Password
$msg =’’;
if(isset($username, $password)) {
ob_start();
include(DOC_ROOT.’/config.php’); //Initiate the MySQL connection
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($username);
$mypassword = stripslashes($password);
$myusername = mysqli_real_escape_string($dbC, $myusername);
$mypassword = mysqli_real_escape_string($dbC, $mypassword);
$sql=“SELECT * FROM login_admin WHERE user_name=’$myusername’ and user_pass=SHA(’$mypassword’)”;
$result=mysqli_query($dbC, $sql);
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file “admin.php”
session_register(“admin”);
session_register(“password”);
$_SESSION[‘name’]= $myusername;
header(“location:admin.php”);
}
else {
$msg = “Wrong Username or Password. Please retry”;
header(“location:index.php?msg=$msg”);
}
ob_end_flush();
}
else {
header(“location:index.php?msg=Please enter some username and password”);
}
?>[/php]
I am not sure if I have to set the username and pass in the check_login as well as the config.php