if(!$user_id)
header("Location: index.php");
if(empty($_GET['id']) || !ctype_digit($_GET['id']))
header("Location: index.php");
$id = $_GET['id']; для безопасности лучше наверно написать так
if(!$user_id)
header("Location: index.php");
if(empty($_GET['id']) || !ctype_digit($_GET['id']))
header("Location: index.php");
$id = intval($_GET['id']);