any help on why its not letting log in would be appreciated, thanks
PHP Code:
<?php
// get login values & hash the password
$username = ($_POST['username']);
$password = sha1($_POST['password']);
// connect to the database
$conn = mysqli_connect('','', '', '') or die('connection error');
// write a sql query
$sql ="SELECT id FROM admins WHERE username = '$username' AND password = '$password'";
echo $sql;
// execute the sql and store the query result
$result = mysqli_query($conn, $sql);
// count the number of rows in the database
$count = mysqli_num_rows($result);
echo $count;
// check the count to see the amount of matches
if($count == 1)
{
echo 'logged in successfully';
// get first record from query
$row = mysqli_fetch_array($result);
// store the id in the session object
session_start();
$_SESSION['user_id'] = $row['id'];
the above statement must occur before any echo's/output, so place it as the first line.
PHP Code:
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
or MYSQLI_BOTH, MYSQLI_NUM.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS