Page 2 of 2

Posted: Sun Aug 06, 2006 3:43 pm
by ekosoftco
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

Posted: Sun Aug 06, 2006 4:38 pm
by RobertGonzalez
OK, post the code.

Posted: Sun Aug 06, 2006 5:51 pm
by ekosoftco
Everah | Please use

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; 
    } 
}
Everah | Removed potentially sensitive information.


Everah | Please use

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]

Posted: Sun Aug 06, 2006 7:10 pm
by RobertGonzalez
OK, first thing, please use the appropriate bbCode tags when posting code. I have cleaned this up for you a few times.

Next, try this...

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;
}
?>

Posted: Sun Aug 06, 2006 10:08 pm
by ekosoftco
its still sending me to the paidonly part of the site, and i have a 1 for paid. i think it might be that my session may not be set (i know nothing about sessions though)
how would i set up the session if its not?

Posted: Sun Aug 06, 2006 10:16 pm
by RobertGonzalez
Post the code where you set all the other user session vars. I will put it into that code.

Posted: Sun Aug 06, 2006 10:37 pm
by ekosoftco
I think it was insterted with a query. Im not exactly sure, i used an extremely stripped login code, and modified it to how i wanted it to work.
Again, i dont know anything about sessions, so if this isnt them being set, i have no idea what to look for, and im sorry for a useless post. :/

INSERT INTO loginphp
(Uname, Email, Pword) VALUES('$ADMINUNAME', '$ADMINEMAIL', '$ADMINPWORD')

Posted: Sun Aug 06, 2006 11:02 pm
by RobertGonzalez
Ok, lets simplify things a bit...

Usually, a login process consists of validation, authentication and/or access control. When a user is validated, session vars are set to include basic information about the user...

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;
}
?>
This is an extremely stripped down method demonstration, but it should give the basic logic of what you want to do.

Posted: Sun Aug 06, 2006 11:46 pm
by ekosoftco
wow, im so retarded. i see it now. its easy lol. sorry, but thank you so much for sticking through and helping me, i really appreciate it. :) i will definitly refer people to this site to give input and output!

Posted: Sun Aug 06, 2006 11:56 pm
by RobertGonzalez
You're not retarded. You're new. We all started somewhere. Keep practicing. Heck, one day you may be here answering people's questions, too.