Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 26th, 2002, 06:27 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Article Discussion: Building a Members Area with PHP: Part 3/6

If you have any questions or comments on this article then please post them here.

This forum post relates to this article

Reply With Quote
  #2  
Old December 12th, 2002, 02:19 AM
markrenn markrenn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 23 markrenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
to distinguish between a public and a private visitor

where should i place this code?

PHP Code:
if($dtlsSecurity->IsLoggedIn()) 

?> 
Menu Items here<br> 
<?php 

else 

?> 
<form method="post" action="login.php"> 
username: <input type="text" name="username"><br> 
password: <input type="password" name="password"><br> 
<input type="submit" value="login"> 
</form> 
<?php 



and what if i have a login form on every page of the site? how can i make it change when a user already has logged in?

a million thanks to any answers!

Reply With Quote
  #3  
Old December 12th, 2002, 05:40 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
place that anywhere you want, just call the session class on every page, and it will keep you logged in on every page

Reply With Quote
  #4  
Old December 12th, 2002, 08:55 PM
markrenn markrenn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 23 markrenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
im sorry for my ignorance but i still didnt get what you mean. what session class are u talking about and how do i use that?

another question i have is what if i want to redirect them to a certain members area page once they logged in successfully, how do i do that?

and how do i use thuis snippet?
PHP Code:
if(!$dtlsSecurity->IsLoggedIn()) 

header("location: login.php"); 




i would really appreciate any response! ,thanks!

Reply With Quote
  #5  
Old December 15th, 2002, 11:41 PM
markrenn markrenn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 23 markrenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
what i did was place a login form on every page so that anytime they want to login, wherever they are in the site, they could do so
this means that once they've logged-in, the login part will then change to a welcome user dialog.

here are some of the errors ive encountered:

Fatal error: Call to a member function on a non-object...

Warning: Cannot send session cache limiter...

could anybody please enlighten me!... thanks

Reply With Quote
  #6  
Old December 16th, 2002, 07:10 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Have you read parts 1 and 2 of this article??

if you dont know what im talking about when I say the security class, i think you need to read the articles again. There is a whole article devoted to the security class.

Reply With Quote
  #7  
Old December 18th, 2002, 04:29 AM
[krim] [krim] is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: latvia
Posts: 4 [krim] User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Damn Damn Damn!?!
Administrators why didn't you give us full code of this articles (member area)? If you give us it full we will understand you!!!
And you will be easier to you.

Reply With Quote
  #8  
Old December 18th, 2002, 06:17 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
If you looked at parts 1,2 & 4, they include support material, which is the code i wrote and tested for the article.

the support material is on the last page of each article.

Also please dont spam on multiple posts

Reply With Quote
  #9  
Old December 19th, 2002, 08:20 PM
mrl14 mrl14 is offline
1 Month Free Hosting!
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 15 mrl14 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ben, first off I want to say that your articles are very helpful as well as the majority of the articles on the site, however I wanted to bring up something. Look at this more as constructive criticism please.

A lot of people want to learn to program because it can be fun and be a nice source of income and that's where sites like devArticles come in handy.
The problem I am having with this site is with some of your replies. You keep telling us that its an intermediate level and if we aren't at that level then to get out of here because we aren't allowed to even try and attempt the article. I can understand how frustrating it can be trying to help someone who doesn't understand the language, but you could make life a lot easier if either of the following are done:

a) the support files contain EVERY single file with proper code mentioned in the article and have been tested to work with no code modifications

b) the articles are colour coded better to determine when code should be added to a page and when you're just reiterating it to explain the code.

Reply With Quote
  #10  
Old December 19th, 2002, 08:48 PM
mrl14 mrl14 is offline
1 Month Free Hosting!
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 15 mrl14 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Anyhow this code just produces an error for me:

<html><head><title>please login</title></head>
<body>


<?
include("class.security.php");

?>


<?
if($dtlsSecurity->IsLoggedIn())
{
?>

Menu Items here<br>

<?php
}
else
{
?>

<form method="post" action="login.php">
username: <input type="text" name="username"><br>
password: <input type="password" name="password"><br>
<input type="submit" value="login">
</form>

<?php
}
?>

</body>
</html>



And there is no support material for Part 1 or 3

Reply With Quote
  #11  
Old December 20th, 2002, 06:45 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Quote:
A lot of people want to learn to program because it can be fun and be a nice source of income and that's where sites like devArticles come in handy.
The problem I am having with this site is with some of your replies. You keep telling us that its an intermediate level and if we aren't at that level then to get out of here because we aren't allowed to even try and attempt the article. I can understand how frustrating it can be trying to help someone who doesn't understand the language, but you could make life a lot easier if either of the following are done:


Ok, the reason why i said you need to have an intermediate level of PHP knowledge is because of the complexity issue of the class, the code, and to put it straight, it is a INTERMEDIATE article. Im not stopping begginners from using the article, its good to see people having a challange.

I love programming, and because of this site im now a professional PHP programmer. If people want to learn, im more then happy to, im also more then happy to help people with problems.

now the reason why im a bit anoyed is because i took my own time to write the article for intermediate programmers. then to recive email after email from 'intermediate' programmers who are actually still begginers, tell me that it doesnt work, and give me an ear full, when in actual fact its there own inability understand and use PHP.

I just find it really anoying when people tell me i have made a mistake, without looking at there own problems first.

Quote:
a) the support files contain EVERY single file with proper code mentioned in the article and have been tested to work with no code modifications


Now i admit there is a spelling mistake in one of the articles, however the source code comes from my own site that im developing, so i know for a fact that it works, as i have been testing the class for over 15hrs.

All the files are included in the support material used.

There is no support for article 3, as there is no need, as i didnt modify any files, and the support material for #2 is the same as #1


the article format is not controlled by me, its controled by our editor, mytch.

With regards to your problem, you need to call the functions that set up the class first. You can find these in part #2. its the same code for the index.php file

Reply With Quote
  #12  
Old December 28th, 2002, 07:25 AM
JXL JXL is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Netherlands
Posts: 13 JXL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
some files r missing in the support material, the 1st time i downloaded this article i had all the files in 1 rar file, now i only have 3

Reply With Quote
  #13  
Old December 30th, 2002, 02:45 PM
msmetsers msmetsers is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: netherlands
Posts: 11 msmetsers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
why doesn't this work??? PLEASE>>>>

In an includefile (a menu...) I carry following code which doesn't work.:
QUOTE==
<?php
if($IsLoggedIn)
{
?>
<td>BLABLA</td>
<?php
}
else
{
?>
<td>BLEBLE</td>
<?php
}
?>
UNQUOTE==

In the file where the include is part I have in top of file following, which I think was as I understood meant to be:
QUOTE==
<?php
ini_set ("include_path",'includes');
include('javascripts.php');
include('class.security.php');
include('header.php');
include('menu.php');

$dtlsSecurity = new Security;

$dtlsSecurity->ExtraFieldNames('firstname,lastname');
$dtlsSecurity->StoreSession_TableName('session');
$dtlsSecurity->Log_TableName('log');
$dtlsSecurity->FieldNames('sessionid', 'userid', 'username', 'auth');

$IsLoggedIn = $dtlsSecurity->IsLoggedIn();
$details = $dtlsSecurity->GetData();


if(!$dtlsSecurity->IsLoggedIn() && !is_numeric(strpos($_SERVER["PHP_SELF"], "login.php")))
{
if($_COOKIE['mem'] != '')
{
header("location: login.php?strMethod=checklogin");
}
}
?>

Any clues why still not working???? Thanks,
Martin

Reply With Quote
  #14  
Old December 30th, 2002, 10:33 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
what happens when you echo out the following?

$dtlsSecurity->IsLoggedIn()


does it print anything?

Reply With Quote
  #15  
Old December 31st, 2002, 01:45 AM
msmetsers msmetsers is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: netherlands
Posts: 11 msmetsers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
echo result

just a "0"

All info is in my database though!
Martin

Reply With Quote
  #16  
Old December 31st, 2002, 03:33 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
that means your not logged in, have you tried logging in?

Reply With Quote
  #17  
Old December 31st, 2002, 03:52 AM
msmetsers msmetsers is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: netherlands
Posts: 11 msmetsers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
re login

definitely! BTW, Appreciate your help.
(As mentioned my login details definitely into database!)
Here's my login page:
QUOTE++
<?php
ob_start();
ini_set ("include_path",'includes');
include('javascripts.php');
include('class.security.php');
include('header.php');
include('menu.php');

$dtlsSecurity = new Security;

$dtlsSecurity->ExtraFieldNames('firstname,lastname');
$dtlsSecurity->StoreSession_TableName('session');
$dtlsSecurity->Log_TableName('log');
$dtlsSecurity->FieldNames('sessionid', 'userid', 'username', 'auth');

$struName = $_POST["struName"];
$strPass = $_POST["strPass"];
$strMethod = $_POST["strMethod"];
echo $IsLoggedIn;
if($strMethod == "")
$strMethod = $_GET["strMethod"];


if(!$dtlsSecurity->IsLoggedIn())
{
switch($strMethod)
{
case "check_login":
ProcessLogin();
break;
case "checklogin";
CheckCookie();
break;
default:
GetLogin();
break;
}

}
else
{
if($strMethod == "logout")
ProcessLogout();
else
ShowLogOut();
}

function CheckCookie()
{



$strQuery = mysql_query("SELECT * FROM users WHERE session = '{$_COOKIE['mem']}'");
if($cookie = mysql_num_rows($strQuery) > 0)
{

//cookie session = stored session, login
$result = mysql_fetch_array($strQuery);
if($dtlsSecurity->StoreSession($result[0], $result[1], $result[3], "{$result[4]},{$result[5]}"))
header("Location: index.php");


}
else
{

//cookie doesnt match any session
setcookie("mem","",time()-1);
header("Location: index.php");


}

}

function GetLogin()
{
?>
<body class="bodyachtergrond"><title>Alleen voor leden van G.C.de Hoogebergsche</title>
<div align="center" class="menheadi"><a href="index.php">Hoofdpagina</a> | <a href="registration.php">Registratie</a> | <a href="login.php">Login</a></div>
<form name="frmLogin" action="login.php" method="post">
<input type="hidden" name="strMethod" value="check_login">
<table align="center">
<tr>
<td width="26%" align="right" class="menheadi"><strong>HB Lidcode&nbsp;&nbsp;</strong></td>
<td width="20">&nbsp;</td>
<td width="74%" class="menheadi"><input name="struName" type="text" value="" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="26%" align="right" class="menheadi"><strong>Paswoord&nbsp;&nbsp;</strong></td>
<td width="20">&nbsp;</td>
<td width="74%" class="menheadi"><input name="strPass" type="password" value="" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="26%" align="right"></td>
<td width="20">&nbsp;</td>
<td width="74%"><input name="strSetCookie" type="checkbox" value="1" checked>Onthouden</td>
</tr>
<?php
if($_POST['strSetCookie'] == 1)
{
mysql_query("UPDATE users SET sessionid = '" . session_id() . "' WHERE username = '$strUser'");
setcookie("mem", session_id(), time()+(3600*24*30*4));
}
?>
<tr>
<td width="26%"></td>
<td width="20">&nbsp;</td>
<td width="74%"><input type="submit" value="Inloggen"></p></td>
</tr>
</form>
</table>
</table>
<?php
}
function ProcessLogin()
{
global $dtlsSecurity;

$strUser = @$_POST["struName"];
$strPass = md5($_POST["strPass"]);

$dbVars = new dbVars();
@$svrConn = mysql_connect($dbVars->strServer, $dbVars->strUser, $dbVars->strPass);

if($svrConn)
{
$dbConn = mysql_select_db($dbVars->strDb, $svrConn);

if($dbConn)
{
$strQuery = "select * from users ";
$strQuery .= "where username = '$strUser' ";
$strQuery .= " and password = '$strPass' ";

$results = mysql_query($strQuery);
$result = mysql_fetch_row($results);

if($result)
{
// Write to the log file
$strLog = "Login OK: {$result[1]}, {$result[3]}, {$result[4]}, {$_SERVER['REMOTE_ADDR']}, " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog($strLog);

// Set the login credentials for this user in the tbl_AdminSessions table
if($dtlsSecurity->StoreSession($result[0], $result[1], $result[3], "{$result[4]},{$result[5]}"))
{

if($_POST['strSetCookie'] == 1)
{

mysql_query("UPDATE users SET sessionid = '" . session_id() . "' WHERE username = '$strUser'");
setcookie("mem", session_id(), time()+(3600*24*30*4));

}


header("Location: index.php");

}
else
{
?>
<table>Kon geen nieuwe sessie starten:<br><br><a href="javascript:history.go(-1)">Terug</a>
</table>
</table>
<?php
}
}
else
{
$strLog = "Login Failed: $strUser, $strPass, {$_SERVER['REMOTE_ADDR']}, " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog($strLog);

?>
<table>
<div align="center" class="menheadi"><a href="index.php">Hoofdpagina</a> | <a href="registration.php">Registratie</a> | <a href="login.php">Login</a></div>
<p>XXX Inloggen mislukt<br><br>
De login gegevens die u gaf zijn niet correct. Maak gebruik van onderstaande
link om terug te gaan en uw HB Lidcode en paswoord te controleren/corrigeren.
<a href="javascript:history.go(-1)">Terug</a><br><br> <br>
Of wanneer u nog niet geregistreerd bent kunt u dat hier doen--->>><a href="registration.php">Registratie</a>
</p>
</table>
</table>
<?php
}
}
else
{
$strLog = "Database Error: Login, $strUser, $strPass, {$_SERVER['REMOTE_ADDR']}, " . mysql_error() . ", " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog($strLog);

?>
<table>Database Error<br><br><a href="javascript:history.go(-1)">Go Back</a></table></table>
<?
}
}
else
{
$strLog = "Database Server Error: Login, $strUser, $strPass, {$_SERVER['REMOTE_ADDR']}, " . mysql_error() . ", " . date("d/m/Y h:i:m A");
$dtlsSecurity->AddLog($strLog);

?>
<table>Database Error<br><br><a href="javascript:history.go(-1)">Terug</a>
</table>
</table>
<?php
}
}

ob_end_flush();

function ShowLogOut()
{

header("Location: index.php");

}

function ProcessLogOut()
{
/*
Function Name: ProcessLogOut()
Paramaters: N/A
Desc: Kills the current session and redirects the user back to the login page
*/

// Delete records matching this session id
session_start();
$dbVars = new dbVars();

@$svrConn = mysql_connect($dbVars->strServer, $dbVars->strUser, $dbVars->strPass);

if($svrConn)
{
$dbConn = mysql_select_db($dbVars->strDb, $svrConn);

if($dbConn)
{
$strQuery = "delete from session ";
$strQuery .= "where sessionid = '" . session_id() . "'";
mysql_query($strQuery);
}
}

header("Location: index.php");
}
include('rightside.php');
?>

Reply With Quote
  #18  
Old January 1st, 2003, 07:52 AM
msmetsers msmetsers is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: netherlands
Posts: 11 msmetsers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Added session_start()

I have now added session_start() to my index page and now echo $IsLoggedIn results in 1! And details show.

Problem remained in the require_once("menu.php") file which is supposed to show something when logged in and not ... so I included the full class.security.php, the session_start() with the $dtlsSecurity lines in the menu.php file and it now works aswell.

Thanks for the support, will prbly come back with new questions but for the moment it looks like solved, so I am happy.

Question remains though why the session_start() is not necessary in your index.php to work correctly and I apparently have to use it. Hope you can still answer that one.

Martin

Reply With Quote
  #19  
Old January 1st, 2003, 05:25 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
to be honest i dont know why you have to call start_session on your index page, as its already called in the security class.

Reply With Quote
  #20  
Old January 22nd, 2003, 06:00 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 17
Great article Ben Rowe,

Everything is working as far as I can see,
But when I try to register the form clears, and no data goes to the database. with no errors.

Register
Form Clears
I check database and no users

Also, I added a user through phpmyadmin, and when I go to log in, it just clears on sumbit.

I double checked everything, maybe I missed something...

Reply With Quote
  #21  
Old January 22nd, 2003, 08:13 PM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 16
Question Confused???

After reading and following all the tutorials again and again...., I have added and modified lots of things in the orginal codes, but I still confuse hoping to find someone or the author of this series articles could help me to clear on this in order for me to go on the actual project. The confused things are:

In the index.php file:
PHP Code:
if(!$dtlsSecurity->IsLoggedIn() && !is_numeric(strpos($_SERVER["PHP_SELF"], "login.php")))
{
if(
$_COOKIE['mem'] != '')
{
header("location: login.php?strMethod=checklogin");
}


Could you please point out where ( strMethod=checklogin ) method is passing from?



And in the login.php
PHP Code:
if(!$dtlsSecurity->IsLoggedIn())
            {

                switch(
$strMethod)
                        {
                                case 
"check_login":
                                        
ProcessLogin();
                                        break;
                                case 
"celogin";
                                        
CheckCookie();
                                        break;
                                default:
                                        
GetLogin();
                                        break;
                        }
                        
            } 

Could you please point out where ( case "celogin" ) method is passing from?



That's all I would like to ask. Thanks.

Reply With Quote
  #22  
Old January 23rd, 2003, 05:05 AM
msmetsers msmetsers is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: netherlands
Posts: 11 msmetsers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
celogin

Must have been a typo, the correct(ed) version reads:

switch($strMethod)
{
case "check_login":
ProcessLogin();
break;
case "checklogin";
CheckCookie();
break;
default:
GetLogin();
break;
}
please see example files
Martin

Reply With Quote
  #23  
Old January 23rd, 2003, 08:04 AM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 16
I have downloaded 3 supported zip files and they are all the same. I am glad that it is clear now, Thanks

Reply With Quote
  #24  
Old February 1st, 2003, 04:47 AM
[krim] [krim] is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: latvia
Posts: 4 [krim] User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
where can i get 1,2,3 part Members script support materials in .zip? badly needed (

Reply With Quote
  #25  
Old February 2nd, 2003, 04:15 PM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 16
A link to the supported files will be at the end of the article. I should be at the en of article 5/6. Go check it out.

Reply With Quote
  #26  
Old February 2nd, 2003, 05:12 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
part 1 is the only part without support material. the other parts have support material at the conclusion of the article. They contain updated code, etc

wareseeker, what do you mean by the following comments

Quote:
Could you please point out where ( strMethod=checklogin ) method is passing from?


and

Quote:
Could you please point out where ( case "celogin" ) method is passing from?


The first one checks to see if the user is not logged in, and is not at the login.php page, if this returns true, it then checks to see if they have previously logged in and stored a session cookie. If they have done this, then you are forwarded to login.php?strMethod=checklogin

Then your second comment, as msmetsers pointed out, that should be checklogin. This will then call the function that checks the cookie, and allows you to login even though you have not entered in your username and password.

The login with cookies function was actually taken from my site in developement, case-extreme.com, hence the celogin. I must have forgotten to change this in the article.

Sorry for the confusion on this.

Reply With Quote
  #27  
Old March 10th, 2003, 11:41 AM
skyrider skyrider is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Netherlands
Posts: 2 skyrider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ExtraFieldNames

After fiddling around a bit, I got everything working but I need a few extra fields in the users table and consequently in the session table. I added the fields in both tables and modified the code where applicable but now, when I try to log in, a "new session could not be started", nothing is added to the session table but a successful login is recorded in the log table...

Is this the right way to define extra fields in "login.php"?:
...
$dtlsSecurity->ExtraFieldNames('firstname,lastname,extrafield1,ex trafield2');
...

and in the "function ProcessLogin()":
...
// Set the login credentials for this user in the tbl_AdminSessions table
if($dtlsSecurity->StoreSession($result[0], $result[1], $result[3], "{$result['firstname']},{$result['lastname']},{$result['extrafield1']},{$result['extrafield2']}")) {
if($_POST['strSetCookie'] == 1) {

... etc, etc.

I would greatly appreciate any help available here...
Thanx in advance!

Rick

Last edited by skyrider : March 10th, 2003 at 05:01 PM.

Reply With Quote
  #28  
Old May 6th, 2003, 07:28 AM
n5ltc n5ltc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Texas
Posts: 2 n5ltc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to n5ltc Send a message via AIM to n5ltc Send a message via Yahoo to n5ltc
Cache limiter error in security class

When I attempt to access the example index.php page I get the following error:

Warning: Cannot send session cache limiter - headers already sent (output started at <path omitted>/variables.php:7) in <path omitted>/class.security.php on line 200
main | Welcome guest, please login or register

This is after I have successfully regsitered and logged in using the register and login pages.

Any suggestions?

BTW, I used the class.security.php code from the support section.

Thanks
Chris

Reply With Quote
  #29  
Old May 7th, 2003, 02:54 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Cache limiter error in security class

Quote:
Originally posted by n5ltc
When I attempt to access the example index.php page I get the following error:

Warning: Cannot send session cache limiter - headers already sent (output started at <path omitted>/variables.php:7) in <path omitted>/class.security.php on line 200
main | Welcome guest, please login or register

This is after I have successfully regsitered and logged in using the register and login pages.

Any suggestions?

BTW, I used the class.security.php code from the support section.

Thanks
Chris


At the very top of the file you will need to call the function

ob_start();

Also do this on the page that you actually call in the browser

Reply With Quote
  #30  
Old May 7th, 2003, 09:01 AM
n5ltc n5ltc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Texas
Posts: 2 n5ltc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to n5ltc Send a message via AIM to n5ltc Send a message via Yahoo to n5ltc
Re: Re: Cache limiter error in security class

Quote:
Originally posted by Ben Rowe


At the very top of the file you will need to call the function

ob_start();

Also do this on the page that you actually call in the browser


Works great now. Thanks!

Now for my next question... I am using the cookie implementation to remember users and I have modified the database to store the sessionID in the users table. However, when I log in with a winXP computer running IE 6+ it doesn't create a cookie. When I use Opera on a Linux box, it does create a cookie. As a result, if I close the browser and re-open it to the index.php page, I have to log in again. When logging in on the XP box, the session ID is logged correctly in the users table on the database. Do I need to have
<snip>
if(!$dtlsSecurity->IsLoggedIn() && !is_numeric(strpos($_SERVER["PHP_SELF"], "login.php")))
{
if($_COOKIE['mem'] != '')
{
header("location: login.php?strMethod=checklogin”);
}
}
</snip>
anywhere but on the index page (or any of my content pages)?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: Building a Members Area with PHP: Part 3/6


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap