How to retrieve value from PHP script within Ajax
So at the top of my HTML page, before the html tag, I've included this
into the page through a include statement:
login.php:
if($_SESSION['user'] == ""){
header("Location: index.php");
die;
} else {
$user = $_SESSION['user']; // student id
$results = mysqli_query($conn, "SELECT * FROM `user` WHERE
`studentid`='$user' LIMIT 1");
$current = mysqli_fetch_array($results);
}
?>
Later on in the page, within HTML tags, I call a page through Ajax and
within that page, I write `echo $user;', however nothing gets printed out.
How do I retrieve the values from my earlier php script here?
Here's the layout:
<?php include('login.php'); ?>
<html>
<head></head>
<body>
<?php //ajax portion of the page
echo $user; //prints nothing
?>
</body>
</html>
No comments:
Post a Comment