Page 2 of 2
Posted: Thu Feb 26, 2004 6:25 pm
by tim
i use:
Code: Select all
<?php
if (isset($var_name)) {
// show your page
} else {
//show your log-in page
}
?>
Posted: Thu Feb 26, 2004 6:28 pm
by monkeyj
actually.. I still wanna use polaks... Cookies have to be enabled for users to get em..
o.o
so.. back to ubers..
does that actually block the page totally?
Posted: Thu Feb 26, 2004 6:30 pm
by monkeyj
rawr.. Ok. I'm stupid.. I just put the code uber gave me in the "page.php" and then if it isn't set.. I KICK EM OUT! bwabhaha
gah.. too advanced for me..
Posted: Thu Feb 26, 2004 6:39 pm
by monkeyj
Ok. yes.. This stuff is over my head..
I think I put it in the right place..
Right after the person logs in.. they go straight to the "checkuser.php"
which is...
Code: Select all
<?php
/* Check User Script */
session_start(); // Start Session
include 'db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'login_form.html';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
session_register('special_user');
$_SESSION['user_level'] = $user_level;
[b]$access = true;[/b]
mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
header("Location: login_success.php");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
include 'login_form.html';
[b]$access = false;[/b]
}
?>
I bolded where I put the access... and.. I don't think it's working...
also...
I think I wanna use cookies now..
would I type:
function setCookie(mbmemberaccess, true, expiredays)
Uhh.. forgot how to never expire...
but.. Would I type it in the same place where I put that access?
Posted: Thu Feb 26, 2004 6:40 pm
by monkeyj
Oops.. Still in the php code.. its not "bolded" .. *shrug* lol
Posted: Thu Feb 26, 2004 6:47 pm
by d3ad1ysp0rk
a ba eh da.. *more gibberish*
how are cookies easier??????
setcookie(name,'value',time);
is less confusing than
$_SESSION['name'] = value;
????
I still think you should keep trying to understand php, cuz no one is going to write the whole code for you..
I've found w3schools to be simple enough:
http://www.w3schools.com/php/default.asp
Posted: Thu Feb 26, 2004 6:53 pm
by tim
i never said cookies was easier, if u read what I did say, it was I thought sessions would be out of monkies grasp seeing hes struggling with if and then statements...
What do I know though, if u can use sessions, use sessions, if you cant, find other means =]
end (gibberish);
Posted: Thu Feb 26, 2004 6:56 pm
by d3ad1ysp0rk
ya but it's not like he knows how to do that either so you'd have to explain that too

Posted: Thu Feb 26, 2004 7:02 pm
by monkeyj

Yes.. but I know how to learn cookies..
Cookies are easier ... to UNDERSTAND.. for me.. I'll look into that w3 thing... After I try..
<?php
if ($access == true) {
include('page.php');
} else {
include('noentry.php');
}
?>
with $SESSION['name'] = value;
Cause I think I've had a revelation

Posted: Thu Feb 26, 2004 7:09 pm
by monkeyj
Mother nature Lashes out at me... o.o
I don't believe it worked...
crap
rawr!
Posted: Thu Feb 26, 2004 7:15 pm
by monkeyj
trying something else now :-d
Posted: Thu Feb 26, 2004 7:17 pm
by tim
monkeyj wrote:trying something else now :-d
I dont think the moderators would approve of this style post...
its pointless, it dont have a meaning to anyone trying to help and its not a questionable statement able to recieve help...
not to be a jackass, but it might save u a harsher beating from someone else on this board in the future...
i'm a lover, not a fighter... unless its over my beer supply.
ok...
Posted: Thu Feb 26, 2004 7:22 pm
by monkeyj
Umm.. okay.. sorry.. lol.. O.o too much coffee?
I have the login successful file with the following script:
Code: Select all
<?
session_start();
echo "Welcome ". $_SESSIONї'first_name'] ." ". $_SESSIONї'last_name'] ."! You have made it to the members area!<br /><br />";
echo "Your user level is ". $_SESSIONї'user_level']." which enables you access to the following areas: <br />";
if($_SESSIONї'user_level'] == 0){
include 'http://monkeyblast.com/babes/';
}
if($_SESSIONї'user_level'] == 1){
echo "- Forums<br />- Chat Room<br />- Moderator Area<br />";
}
echo "<br /><a href=logout.php>Logout</a>";
?>
In this code I've obviously included the babes folder of my site...
now... I still don't see how I can not allow the person if there not even logged in.. the user_level = 0 is the access lvl when you first sign up... and that's really what I see I need.. cause I just want the members to access something when theyre only a member and just a member.. not some senior member..
Again the chat/forum/moderator isn't mine.. but I'll change that later...
But now.. How can i prevent them from getting into a page I'm going to make user_level 0 link too...