Why this code doesn't redirect to profile page? i need help..
<?php
include('connectvars.php');
if(isset($_POST['login']))
{
$con = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
$user_username = mysqli_real_escape_string($con,trim($_POST['username']));
$user_password = mysqli_real_escape_string($con,trim($_POST['password']));
if(!empty($user_username) && !empty($user_password))
{
$query = "SELECT * from Account where Username = '$user_username'";
$data = mysqli_query($con,$query);
if(mysqli_num_rows($data) == 1)
{
$row = mysqli_fetch_array($data);
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['username'] = $row['username'];
setcookie('user_id', $row['user_id'], time() + 60); // expires in 30 days
setcookie('username', $row['username'], time() + 60); // expires in 30 days
$profile_url = 'http://localhost/RegenWeb/profile.php';
header('Location: ' . $profile_url);
}
}
mysqli_close($con);
}
?>