<?php
$unique_id = $_REQUEST['u']; 
session_start();
if(isset($_SESSION[$key]) && $_SESSION[$key] === true){
    header("location: Dashboard.php");
    exit;
}
	    require_once "DBConfig.php";
		$unique_id = $_REQUEST['u']; 
	 	
		$result = mysqli_query($link,"SELECT * FROM user_table WHERE unique_key='".$unique_id."'");
	if(mysqli_num_rows($result)>0) 
	{
			while($row = mysqli_fetch_array($result)) 
			{
				 session_start();
                 //$_SESSION["admin"] = true;
                 $_SESSION["user_id"] = $row["user_id"];
                 $_SESSION["fullname"] = $row["fullname"];
				 $_SESSION["unique_key"] = $row["unique_key"];
				 $key=$row["unique_key"];
				 $_SESSION[$key] = true;
				 header("location: Dashboard.php?u=$key");
			}
	}
	else
	{
   		echo '<script type="text/javascript">
       window.onload = function () { alert("Error: please try again");
	   window.location.href="index.php";} </script>'; 
	}
?> 
  