Skip to content

Instantly share code, notes, and snippets.

@AriffAzmi
Created September 30, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AriffAzmi/6b7cc2bdbd49282ddf2e to your computer and use it in GitHub Desktop.
Save AriffAzmi/6b7cc2bdbd49282ddf2e to your computer and use it in GitHub Desktop.
<?php
include_once 'dbconfig.php';
if (!isset($_SESSION['id'])) {
echo '<script>'. 'alert("Please login");'. '</script>';
echo '<script>'. 'window.location.href="login.php";'. '</script>';
}
$user_id = $_SESSION['id'];
$stmt = $conn->prepare("SELECT * FROM users WHERE id=:user_id");
$stmt->bindParam(':user_id', $user_id);
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment