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:
  #31  
Old September 21st, 2003, 02:32 PM
MarnixK MarnixK is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 MarnixK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
copy of articles

Does someone has a copy of the articles. I have to restore a crashes site with this login system, but not all is recovered.

The original link is not working anymore.

Reply With Quote
  #32  
Old September 21st, 2003, 08:43 PM
DDDooGGG DDDooGGG is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Melbourne, Australia
Posts: 97 DDDooGGG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 17
I only have the upto part 5 file, did you get the script working correctly? I could never get the cookie working properly, any help would be appreciated.
hope this help,
Attached Files
File Type: zip members_area5.zip (24.0 KB, 572 views)
__________________
regards,


Fulton

Reply With Quote
  #33  
Old September 22nd, 2003, 02:01 AM
MarnixK MarnixK is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 MarnixK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I changes the original code a little because I didn't need all.
But what I do need is the db structure, after that I can look how I did the cookie thing, it worked with me

Reply With Quote
  #34  
Old September 22nd, 2003, 02:23 AM
DDDooGGG DDDooGGG is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Melbourne, Australia
Posts: 97 DDDooGGG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 17
Could you readthis post i posted and let me know what you have done, thanks.

DATABASE STRUCTURE
PHP Code:
#
# Table structure for table `log`
#

CREATE TABLE log (
  
logId int(14NOT NULL auto_increment,
  
data text NOT NULL,
  
PRIMARY KEY  (logId)
TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `session`
#

CREATE TABLE session (
  
id int(14NOT NULL auto_increment,
  
sessionid varchar(255NOT NULL default '',
  
username varchar(20NOT NULL default '',
  
auth int(14NOT NULL default '0',
  
userid int(14NOT NULL default '0',
  
firstname varchar(50NOT NULL default '',
  
lastname varchar(50NOT NULL default '',
  
PRIMARY KEY  (id)
TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `users`
#

CREATE TABLE users (
  
userId int(14NOT NULL auto_increment,
  
username varchar(40NOT NULL default '',
  
password varchar(255NOT NULL default '',
  
level int(5NOT NULL default '0',
  
firstname varchar(50NOT NULL default '',
  
lastname varchar(50NOT NULL default '',
  
sessionid varchar(255NOT NULL default '',
  
type varchar(10NOT NULL default '',
  
email varchar(50NOT NULL default '',
  
PRIMARY KEY  (userId)
TYPE=MyISAM

Last edited by DDDooGGG : September 22nd, 2003 at 02:26 AM.

Reply With Quote
  #35  
Old September 23rd, 2003, 04:40 AM
MarnixK MarnixK is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 MarnixK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it works again

Well everything is working again, first I have to thank you for the help. I will tell you how I got it working. I will not post much code, because I do not use all of the code published. The dbs are almost the same, so that's no problem.


I have a header file that is included at the top of every file. It contains the header image and display a link menu for my page.
The top of the header file looks like this :

PHP Code:
require('config.inc.php');
 
ob_start(); 

 if (!
IsLoggedIn())
  { if (isset(
$_COOKIE['mem']))
     { if(
$_COOKIE['mem'] != '')
        { 
header("location: login.php?strMethod=checkcookie");
        }
     }
  } 


This works for me.
Maybe a little hint, if your cookies aren't working, at a query to the function that inserts a log description in the log table. I had a problem too with the cookie login. Than I added a simple statement like this when cookie is ok:
PHP Code:
 $strLog 'Login Cookie Ok :'.$logindata->username.' | '.$logindata->userId;
 
$nu time();
 
$datum date('d-m-Y | H:i'time());
 
$query db_query("insert into log set data='$strLog', datum='$datum', udate='$nu'"); 

and the following when the cookie was wrong :
PHP Code:
 $strLog 'Eaten Cookie';
 
$nu time();
 
$datum date('d-m-Y | H:i'time());
 
$query db_query("insert into log set data='$strLog', datum='$datum', udate='$nu'"); 

After that I tried again to login with a cookie set and I saw that the login was oke, but after that it eated my cookie and logged me out.
My cookie function looks like this :
PHP Code:
function CheckCookie()
$sescookie $_COOKIE["mem"];
  
$userquery db_query("select * from users where sessionid='$sescookie'");
  
$cookie mysql_num_rows($userquery);
  if(
$cookie 0)
   { 
// cookie data ok -> login
     
$logindata mysql_fetch_object($userquery);
     
$strLog 'Login Cookie Ok :'.$logindata->username.' | '.$logindata->userId;
     
$nu time();
     
$datum date('d-m-Y | H:i'time());
     
$query db_query("insert into log set data='$strLog', datum='$datum', udate='$nu'");
     if (!
session_id()) 
      { 
session_start();
      }
     
$userinfo = new Object;
     
$userinfo->firstname $logindata->firstname;
     
$userinfo->lastname $logindata->lastname
     
$userinfo->userId $logindata->userId;
     
$userinfo->lastname $logindata->lastname;
     
$_SESSION["userinfo"] = $userinfo;
     
$query db_query("delete from session where userid='".$userinfo->userId."'");
     
$strUser $logindata->username;
     
$query db_query("insert into session set sessionid='".session_id()."',username='$strUser',userid='$userinfo->userId'");
     
mysql_query("UPDATE users SET sessionid = '" session_id() . "' WHERE userId = '$userinfo->userId'");
     
setcookie("mem"session_id(), time()+(3600*24*30*4));
     
header("Location: index.php");
   }
  else
   { 
//cookie not oke 
     
$strLog 'Eaten Cookie';
     
$nu time();
     
$datum date('d-m-Y | H:i'time());
     
$query db_query("insert into log set data='$strLog', datum='$datum', udate='$nu'");
     
// Destroy false cookie
     
setcookie("mem"session_id(), time()-1);
     
$referrer 'index.php';
     
header('Location: '.$referrer);
   }


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: Building a Members Area with PHP: Part 1/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