This is my code for my login form at the moment, but it just doesn’t seem to be working. I’ve meddled with things so much that I’m not even sure what’s wrong any more.
[php]<?php
if(isset($_POST[‘login’]))
{
$username = $_POST[‘username’];
$password = md5($_POST[‘password’]);
$res = $mysqli->prepare(“SELECT * FROM users
WHERE username
= ? && password
= ?”);
$res->bind_param(“ss”, $username, $password);
$res->execute();
$res->store_result();
$rows = $res->num_rows;
if($rows == 0)
{
header (‘Location: …/index.php’);
}else{
$query = “SELECT id
FROM users
WHERE username
= $username”;
if ($stmt = $mysqli->prepare($query))
{
$stmt->execute();
$stmt->bind_result($id);
while ($stmt->fetch_assoc())
{
$_SESSION[‘uid’] = $id;
header (‘Location: …/yourstory.php?id=’.$_SESSION[‘uid’]);
}
}
}
}
?>[/php]
Any help is greatly appreciated.