Hi, i am trying to create my login script for my website, however when i enter my details it does not do anything, it just goes to the same screen. I have used the same script roughly as i used for another website of mine, but i cannot figure this one out. Any advice i would greatly appreciate it.
<?php
// Start Session to enable creating the session variables below when they log in
session_start();
// Force script errors and warnings to show on page in case php.ini file is set to not display them
error_reporting(E_ALL);
ini_set('display_errors', '1');
//-----------------------------------------------------------------------------------------------------------------------------------
// Initialize some vars
$errorMsg = '';
$username = '';
$password = '';
$remember = '';
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if (isset($_POST['remember'])) {
$remember = $_POST['remember'];
}
$username = stripslashes($username);
$password = stripslashes($password);
$username = strip_tags($username);
$password = strip_tags($password);
// error handling conditional checks go here
if ((!$username) || (!$password)) {
$errorMsg = 'Please fill in both fields';
} else { // Error handling is complete so process the info if no errors
include 'connect_to_mysql.php'; // Connect to the database
$username = mysql_real_escape_string($username); // After we connect, we secure the string before adding to query
$password = mysql_real_escape_string($password); // After we connect, we secure the string before adding to query
$password = md5($pass); // Add MD5 Hash to the password variable they supplied after filtering it
// Make the SQL query
$sql = mysql_query("SELECT * FROM user_info WHERE username='$username' AND password='$password' AND verified_email='1'");
$login_check = mysql_num_rows($sql);
// If login check number is greater than 0 (meaning they do exist and are activated)
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
// Pleae note: Adam removed all of the session_register() functions cuz they were deprecated and
// he made the scripts to where they operate universally the same on all modern PHP versions(PHP 4.0 thru 5.3+)
// Create session var for their raw id
$id = $row["id"];
$_SESSION['id'] = $id;
// Create the idx session var
$_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id");
// Create session var for their username
$username = $row["username"];
$_SESSION['username'] = $username;
// Create session var for their password
$userpass = $row["password"];
$_SESSION['userpass'] = $userpass;
mysql_query("UPDATE user_info SET last_login=now() WHERE id='$id' LIMIT 1");
} // close while
// Remember Me Section
if($remember == "yes"){
$encryptedID = base64_encode("g4enm2c0c4y3dn3727553$id");
setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days
setcookie("passCookie", $pass, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days
}
// All good they are logged in, send them to homepage then exit script
include_once 'profile.php?test=$id';
exit();
} else { // Run this code if login_check is equal to 0 meaning they do not exist
$errorMsg = "Incorrect login data, please try again";
}
} // Close else after error checks
} //Close if (isset ($_POST['uname'])){
?>
Thanks