Member System

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

i use:

Code: Select all

<?php
if (isset($var_name)) {
// show your page
} else {
//show your log-in page
}
?>
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

Post 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?
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

Post 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
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

gah.. too advanced for me..

Post 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?
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

Post by monkeyj »

Oops.. Still in the php code.. its not "bolded" .. *shrug* lol
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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);
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

ya but it's not like he knows how to do that either so you'd have to explain that too :P
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

Post by monkeyj »

:P 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 :P
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

Post by monkeyj »

Mother nature Lashes out at me... o.o
I don't believe it worked...

crap
rawr!
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

Post by monkeyj »

trying something else now :-d
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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.
User avatar
monkeyj
Forum Commoner
Posts: 82
Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:

ok...

Post 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&#1111;'first_name'] ." ". $_SESSION&#1111;'last_name'] ."! You have made it to the members area!<br /><br />";

echo "Your user level is ". $_SESSION&#1111;'user_level']." which enables you access to the following areas: <br />";

if($_SESSION&#1111;'user_level'] == 0)&#123;
	include 'http://monkeyblast.com/babes/';
&#125;
if($_SESSION&#1111;'user_level'] == 1)&#123;
	echo "- Forums<br />- Chat Room<br />- Moderator Area<br />";
&#125;

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...
Post Reply