So after my incident last night with the Upwork freelancer I hired sending me some suspicious code, I decided to look through some things.
I wasn't familiar with the login process, but learned that he used md5.
After doing some research, both on here and other sites, I decided to switch the process to bcrypt.
I found a step-by-step resource here I verified that the password is posting to the database correctly.
My login form uses newlogin_check.php to verify the login, but upon submitting the login form, it directs to newlogin_check.php as a blank page.
Here's the code for newlogin_check.php -- just not sure where the error is.
<?php
include("ajax/db_connection.php");
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM logins where userid='$username'";
$result = mysqli_query($con, $query);
$numRows = mysqli_num_rows($rs);
if($numRows == 1) {
$row == mysqli_fetch_assoc($result);
if (password_verify($password, $row['password'])) {
session_start();
$_SESSION["username"] = $row['firstName'].' '.$row['lastName'];
$_SESSION["userid"]= $row['userid'];
$_SESSION["role"] = $row['userType'];
if($_SESSION["role"]=="RF")
header("Location: ref_status.php?uid=".$row['userid']);
else
header("Location: referral.php");
}
else {
header("Location: index.php?errLogin=1");
}
}
}
?>
Edit: db_connection.php file per request
<?php
// Connection variables
$host = "localhost"; // MySQL host name eg. localhost
$user = "USERNAME"; // MySQL user. eg. root ( if your on localserver)
$password = "PASSWORD"; // MySQL user password
$database = "DATABASE"; // MySQL Database name
// Connect to MySQL Database
$con = new mysqli($host, $user, $password, $database);
// Check connection
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
?>