how do i display data on a page from mysql
Posted on
16th Feb 2014 07:03 pm by
admin
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a session
Code: <?php
include_once 'Connect.php';
if (!is_authed())
{
die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.');
}
?>
connect.php i use to conect to database this also does a included to functions.php
this is part of my functions.php
Code: function user_login($username, $password)
// Now encrypt the data to be stored in the session
$encrypted_id = md5($user['id']);
$encrypted_name = md5($user['username']);
// Store the data in the session
$_SESSION['id'] = $id;
$_SESSION['username'] = $username;
$_SESSION['encrypted_id'] = $encrypted_id;
$_SESSION['encrypted_name'] = $encrypted_name;
}
function is_authed()
{
// Check if the encrypted username is the same
// as the unencrypted one, if it is, it hasn't been changed
if (isset($_SESSION['username']) && (md5($_SESSION['username']) == $_SESSION['encrypted_name']))
{
return true;
}
else
{
return false;
}
}
lastly if i want do display info from the database where it matches the session being used
What code would if any would i use to compliment the code in the first question and what code would i enter into the table below
Code: <html>
<head></head>
<body>
<table>
<tr>
<td>feild1 from database here</td>
<td>feild2 from database here</td>
<td>feild3 from database here</td>
</tr>
</table>
</body>
</html>
No comments posted yet
Your Answer:
Login to answer
167
30
Other forums
constructor ?
i have written this program and made 3 constructors in the class and i want to call them in the main
a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca
Problem executing bash script using shell_exec
Hi there,
I created a bash script file using following code to convert doc documents to pdf using
Changing files over
Just thought I'd start with the new forums looking really nice .
Ok basically I've made this
jquery validation in codeIgniter
hai i need to add client side validation to my fiels which are selected in a forloop.the fields are
Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is
Date Question
I'm using the TIMESTAMP() function within mysql to set the date/time for certain events. However, ho
creating a 1 to 100 in a table
hi guys I am a newb in php need some help.
I have a table with 1 column and 100 rows and in
problem with refreshing
in my site, i have an index page, it has a main div. this main div's content is changing according t
Login Script Issues
I am using a script I got from http://phpsense.com/php/php-login-script.html in order to allow peopl