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
small inaccuracies
I have this code to convert fractional base 10 into base 2:
while($num > 0)
Save file by click
Hello.
I'm not understand how to save file from page. I'd like make link to file with save abil
Sessions work for me and not others?
I'm having a bit of bad luck with sessions. In the past they have worked fine for me, but this time
How can i use [] tags instead of <> tags for profiles??
On my site im making ive made it so u can register, login and u have a profile which u can update..<
I need desperate help with this php code integrated with flash please
Can someone please help me with this php code which I have been stuck on for weeks . I am trying to
MS Exchange 2007 integration with ECC 6.0
Hello Experts,
We have ECC 6.0 and MS Exchange 2007. We need to integrate ECC 6 and MS Excha
TemplatePower & AJAX
Hi all,
I'm currently implementing some AJAX features in my PHP-framework (which is b
sql problems
I am having a small problem with my sql statement. it is inserting into 4 of the fields.
fie
unexpected T_STRING
error log "[Sat Jan 09 18:27:58 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error
Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and