[code=php]<?php
// start the session
session_name(‘pickles’);
session_set_cookie_params(900);
session_start();
// require the connectionn and salt settings
require_once(“path_to_connection”);
require_once(“path_to_salt”);
// connect to the database
$conn = sAccess();
// process the form
if (array_key_exists(‘login’, $_POST) && ! empty($_POST[‘login’]))
{
// create an empty array for missing fields
$missing = array ();
/* here, I’m going to create an
array to hold the form fields.
if the form fields are empty,
I’ll add them to the $missing
array. */
$fields = array (“F_Username”=>$_POST[‘username’], “F_Pwd”=>$_POST[‘pwd’]);
foreach ($fields as $field=>$value)
{
if (empty($field))
{
array_push($missing, $field);
}
}
// if $missing is empty, continue the processing
if (empty($missing))
{
// assign the form fields to variables
$username = md5($salt . md5($fields[“F_Username”] . $salt));
$pwd = md5($salt . md5($fields[“F_Pwd”] . $salt));
$query = “SELECT user_id, username FROM users WHERE username= ? AND pwd = ? LIMIT 1”;
// prepare the statement
if ($stmt = $conn->prepare($query))
{
$stmt->bind_param(‘is’, $id, $username);
// execute
if ($stmt->execute())
{
$stmt->bind_result($id, $username);
if ($stmt->fetch())
{
$_SESSION[‘news’] = true;
$_SESSION[‘id’] = $id;
$_SESSION[‘username’] = $username;
$stmt->close();
header(“Location: https://uhrebirth.com/staff/admin_center.php”);
exit;
}
}
}
}
}
?>
I can’t firgure out what’s wrong. When you try to login, it’s like it’s not able to pull anything out of the database, or else that the records in the database don’t exist. However, I checked my database, and they do indeed exist.