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())
Did you know?Explore Trending and Topic pages for more stories like this.
{
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
56
43
Other forums
Blocking video streaming
Hello everyone,
I post a message here because i didn't find any solution yet.
I just finis
php mysql script to find record
Hi,
Currently I have a simple table with 4 columns. A, B, C, D
If I want to find all
Getting the full city list from maxminds geoip database
I am suprised I can't find any references to this.
I have maxminds geoip lite installed and i
need to add "sizes" to shopping cart
Hey guys, I am trying to figure out a way to add a "size" selector on to this bit of code.
Form File Upload
I've read through tons of resources and tutorials and as far as I can tell, my code is accurate, but
PHP SUBMIT
Code: <input name="doLogin" type="image" src="images/loginsubmit.jpg
Pre-Fill out a PHP form...??
This is for work actually (geek squad). We have to fill out this online php form at work over and ov
Code Review - SQL and Insertion Attacks (Warning: Not for Newbs)
Hey guys,
Its been a while, I know. Use to love coming here to answer peoples questions, but
AutoChoosing a CSS file based on URL
Hey everyone,
I have a site that has multiple URLs and CSS files.
Based on the URL tha
Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out wh