Posted: Sun Aug 06, 2006 3:43 pm
i set the field paid to a tinyint and set my account to 1, and tested with another account that has no paid value, and it still lets the person with no value on the page
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
include("top.php");
//top.php is the database connection settings only, along with a welcome username and 3 image links
session_start();
if (isset($_SESSION['Paid']))
{
if ($_SESSION['Paid'])
{
// Let me in!
}
else
{
header("paidonly.php");
exit;
}
}Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
include("top.php");
// top.php is the database connection settings only,
// along with a welcome username and 3 image links
// Start the session here
session_start();
// First things first, check the paid session var
if (isset($_SESSION['Paid']))
{
// Ok, the session var 'Paid is set
if ($_SESSION['Paid'])
{
// Session var 'Paid' is true (or 1)
// Let me in!
}
else
{
// Session var 'Paid is false (or 0)
// Redirect to A FULL URL AS PER THE MANUAL
header("Location: http://www.mysite.com/paidonly.php");
exit;
}
}
else
{
// Session var 'Paid' is not set,
// Redirect to A FULL URL AS PER THE MANUAL
header("Location: http://www.mysite.com/paidonly.php");
exit;
}
?>Code: Select all
<?php
session_start();
$user_validated = false;
// after the login checking and validation...
// maybe during the data fetch from the database
while ($row = mysql_fetch_array($result))
{
$user_validated = true;
$_SESSION['username'] = $row['username'];
$_SESSION['userlevel'] = $row['userlevel';
// This would be a great place to handle the paid var
$_SESSION['userpaid'] = $row['userpaid'];
}
if ($user_validated)
{
header("Location: http://www.mysite.com/goodlogin.php");
exit;
}
else
{
header("Location: http://www.mysite.com/badlogin.php");
exit;
}
?>