Forum Moderators: coopster
This is what I am trying to do:
I want to present all my content to my visitors to allow them to see what I have created. But, only users who have logged in can directly access these links. If a user has not logged in, they are presented with the login page and then sent to the appropriate page.
I serve the links from a php DB - I have a php script that checks for session ID and tells someone if they have logged in or not in the body of my page, but am confused/unaware of how to add this type of functionality to my page and DB.
Is there a way to put this authentication into my DB, with the piece that where session auth = no adds the link to the login page?
<?php
if (@$_SESSION['auth']!= "yes")
{
include("incfiles/logout.inc");
} else {
include("getloginfo.inc");
echo "<html><b>
<body>
Welcome Back $firstName $lastName </b> ¦ ";
include("incfiles/welcome.inc");
}
?>
Thanks! I hope that was clear!
Well your logic is mostly already there. It should look something like this:
if(isset($_SESSION['auth']) && ($_SESSION['auth'] == "yes")) {
//connect to db
//select links from db
//print links
} else {
echo 'You must be logged in to view this page';
include('login.html');
}
Good luck!