So I have a simple working user log in script that carries forward myusername and mypassword.
What I am trying (and failing) to do is recall a specific piece of information from that users Mysql database to modify the page that they are on.
MYSQL DATABASE ('members'):
id:1
username:cornellmatt
password:encrypted(md5)
email:[email protected]
active: 0/1
**permission:1**
The field I need to extract is permission, as it holds the number that will relate the the scene that the user is currently on. In order to do this I am running Jquery on the page that you arrive at after logging in, that links to connect.php
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$.get("connect.php", function(data) {
alert("Data Loaded: " + data);
});
I understand that there are all kinds of problems with my JavaScript at the moment, but for now I want to get the server side stuff done so I can focus on the JavaScript fully The (Current) problem with my Php is that it doesn't seem to be getting anything from the database at all, I know it is connected, it just wont echo the value inside 'permission';
connect.php:
<?php
include "Session.php";
$dbhost = "host";
$dbuser = "username";
$dbpass = "password";
$dbname = "databasename";
//Connect to MySQL Server
mysql_connect($dbhost, $dbuser, $dbpass);
//Select Database
mysql_select_db($dbname) or die(mysql_error());
// Retrieve data from Query String
//this selects everything for the current user, ready to be used in the script below
$result = mysql_query("SELECT * FROM members WHERE username = '$myusername' LIMIT 1");
//this function will take the above query and create an array
while($row = mysql_fetch_array($result))
{
//with the array created above, I can create variables (left) with the outputted array (right)
$permission = $row['permission'];
}
echo '<u><b>Permision ID:</b></u> - - No:' . $row['permission'] ;
?>
If you are wondering what'Session.php' is, it is a script that handles the startup, and is the reason I know I am still logged in. Courtesy of Daryl Gill who helped me in a previous post.
Session.php
<?php
session_start();
if (!isset($_SESSION['Username']))
{
include "Logout.php";
exit;
// session is not set, so enforce logout
}
?>
So my quest is, Why doesn't connect.php echo the value permission, even when I go to the page direct? Please help, I am currently coding this for my student project and have been going in circles for days.