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 8th, 2002, 05:02 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 1/6

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

This forum post relates to this article

Reply With Quote
  #2  
Old November 25th, 2002, 10:45 AM
eqjones eqjones is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: South Carolina
Posts: 18 eqjones User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm having a problem with the security class. Going back through it I found that the GetData function has:

5 - {

and

7 - }

One of them is the ending } for the class. So that leaves me with one missing. I think I added them in the right place, but I'm really not sure.

---------------

I had to '//' comment out the 'session_start(); ' from the IsLoggedIn() function and the GetData() function in class.security.php for this to run without error messages. At this time I have no idea what that will do to the program.

--------------

In article 2, the index.php uses register.php when it should use registration.php.

Also in article 2, in login.php this line has an extra space in it that causes an error:
if($dtlsSecurity->StoreSession($result[userId ], $result[username], $result[level], "{$result[firstname]},{$result[lastname]}"))

There is a space in ['userID '] ... should be ['userID']

---------------

Last edited by eqjones : November 25th, 2002 at 12:37 PM.

Reply With Quote
  #3  
Old November 25th, 2002, 12:41 PM
eqjones eqjones is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: South Carolina
Posts: 18 eqjones User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
I had to '//' comment out the 'session_start(); ' from the IsLoggedIn() function and the GetData() function in class.security.php for this to run without error messages. At this time I have no idea what that will do to the program.


I found out that I had saved a couple returns after the last '?>' in my variables.php and classes.db.php. When I removed the returns the errors went away.

However, for some reason I get a "Couldn't start new session" message after I try to log in.

Reply With Quote
  #4  
Old November 25th, 2002, 03:08 PM
eqjones eqjones is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: South Carolina
Posts: 18 eqjones User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Oh, lol, there is updated source code at the end of the 2nd tutorial. I had cut and pasted the tutorials, which still has bugs in it (or at the time I'm posting this it does.)

Reply With Quote
  #5  
Old November 25th, 2002, 08:35 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Could you please tell me where the bugs are so that i can remove them.

If i did make any mistakes im very sorry to have mislead you.

As eqjones said the updated material in the second article should work.

Reply With Quote
  #6  
Old December 4th, 2002, 04:01 PM
Scurvy Scurvy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 Scurvy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A couple problems

I fixed a few things (probably just typo's) but I keep getting the following errors:
This first one shows up in all the pages:
Warning: open(/tmp\sess_44b00d8a8eca8b7989c2efd8a4de16a9, O_RDWR) failed: No such file or directory (2) in c:\apache\htdocs\class.security.php on line 182

You have now logged in.

Warning: open(/tmp\sess_44b00d8a8eca8b7989c2efd8a4de16a9, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

Line 175 - 187:
PHP Code:
/* 
Function Name: IsLoggedIn() 
Paramaters: N/A 
Desc: Checks if the current user has a session id. If the session id 
is valid, then true is returned. If not false is returned. 
*/ 

182 -> session_start(); 

// Check that the session id is valid 
$dbVars = new dbVars(); 

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


Other than that I don't have any problems

Scurvy

Last edited by Scurvy : December 4th, 2002 at 04:06 PM.

Reply With Quote
  #7  
Old December 4th, 2002, 04:13 PM
Scurvy Scurvy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 Scurvy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It seems that by commenting out all of the session*()'s no error's are encountered. However, isn't this the point of the exercise?

Here's what happens with the index.php:

Warning: Cannot send session cache limiter - headers already sent (output started at c:\apache\htdocs\variables.php:8) in c:\apache\htdocs\class.security.php on line 215

Warning: open(/tmp\sess_44b00d8a8eca8b7989c2efd8a4de16a9, O_RDWR) failed: No such file or directory (2) in c:\apache\htdocs\class.security.php on line 215
main | Welcome guest, please login or register
Warning: open(/tmp\sess_44b00d8a8eca8b7989c2efd8a4de16a9, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

Reply With Quote
  #8  
Old December 4th, 2002, 06:43 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
the problem is that your server isnt set up to handle sessions. This is why its comming up with

Warning: open(/tmp\sess_44b00d8a8eca8b7989c2efd8a4de16a9, O_RDWR) failed: No such file or directory (2) in c:\apache\htdocs\class.security.php on line 215
main | Welcome guest, please login or register
Warning: open(/tmp\sess_44b00d8a8eca8b7989c2efd8a4de16a9, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

because you are running on windows, to use sessions, create a tmp folder in your c:

This will fix those errors. The other errors, that you are having is because your server is set up to send out the data while its processing, not after its processed. because of this, you are getting header errors/

please ob_start();

at the begginning of the security class. to stop these errors from happening. This will allow you to call the header info more then once.

Reply With Quote
  #9  
Old December 12th, 2002, 03:17 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: 16
On the index.php i get the following error:
im using iis 5.1 XP

Notice: Undefined variable: arrRet in c:\inetpub\wwwroot\dynamicphp\login\class.security .php on line 274

Notice: Undefined index: mem in c:\inetpub\wwwroot\dynamicphp\login\index.php on line 17
main | Welcome guest, please login or register

Am downloading Apache, and will be installing it soon, ill let you know how i do.
__________________
regards,


Fulton

Reply With Quote
  #10  
Old December 12th, 2002, 05:00 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: 16
Installed Apache and still does nt work so now i am donloadigf the new release of PHP version 4.3.0RC3 for windows.
Strange thing is <?php phpinfo() ?>
displays all the server variables and information thats it supposed to.

thanks for your help in advance.

Reply With Quote
  #11  
Old December 14th, 2002, 05:48 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: 16
I have changed the error reporting level with by adding the following to each page:

error_reporting(0);

Reply With Quote
  #12  
Old December 15th, 2002, 02:38 PM
AmericanD AmericanD is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 81 AmericanD User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
why do we use ob_start and ob end flush or something in this script ?

i mean whats the use for these buffer start and stop ?
__________________
Hungry for Code

Programming works best with a team over one single person

Reply With Quote
  #13  
Old December 15th, 2002, 07:04 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
some ppl have to use ob_start because of there server setup.

Some servers are very sentive when you use header like functions thats why you use ob_start to suppress the header errors

Reply With Quote
  #14  
Old December 19th, 2002, 07:04 PM
edible_enigma edible_enigma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 edible_enigma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question question!

Hello. I'm getting ready to re-do my site using templates and logins and all that fancy jazz, mainly for fun, but maybe my site will get viewed more and i'll probably update it more often etc... anyways, I'm still learning PHP and MySQL, and I have a question about one of the if statements in the first login tutorial (in the security class).

if($result = @mysql_fetch_array($results))

I understand what the function of that if statement is (it makes sure that the query returned something)... but what I don't get is why you used that instead of if($result != '') or something of that sort... I guess I just don't understand how the mysql_fetch_array() function works. My book here says it returns the next row as an array, but I don't see how that applies here or how it works. I guess I interpreted the description of the function as that it returns the next row in the table... and I don't understand how the next row in the table could equal the one before it. Could you please tell me how it works so that I can further my knowledge of PHP? I would appreciate it very much.

Reply With Quote
  #15  
Old December 19th, 2002, 07:09 PM
edible_enigma edible_enigma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 edible_enigma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I should have included this in my last post... but I just have another general PHP question. In many of the MySQL queries you surrounded the variables in french braces {}... for example,

$strQuery = "SELECT {$this->__FieldNameSess}, {$this->__FieldNameSec} FROM {$this->__StoreSessionTableName} ";


I'm just curious as to what surrounding the variables in french braces does, because I've seen it in other tutorials, and didn't get it. It's not in my book (I only know what's in my book), so I figure it's something new in PHP4 that my book just doesn't cover.

Reply With Quote
  #16  
Old December 20th, 2002, 06:29 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
ok, firstly

if($result = @mysql_fetch_array($results))

returns the data from the database as an array, we need this data for the function.

basically that means if it can retrive the data, return true, otherwise there was some sort of error, so return false.

$strQuery = "SELECT {$this->__FieldNameSess}, {$this->__FieldNameSec} FROM {$this->__StoreSessionTableName} ";

When you suround varaibles in {} it tells php where the variable is, this needed for $this->__FieldNameSess in a string as it confuses PHP otherwise and will return an error.

Reply With Quote
  #17  
Old January 7th, 2003, 04:48 PM
edible_enigma edible_enigma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 edible_enigma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
wee

I modified the code a little bit, and put it on my website, and so far it seems to be working great. It's not on the internet yet... I have lots to code, and I just thought that this isloggedin() thing was a great idea. As I get more and more ideas for my site, a few flaws have come to light. First of all, the database that holds the session data will just keep getting bigger and bigger... and it is possible for the server to create two identical sessionIds. I just have to write a little bit of code and I'll be able to delete rows when I feel it's necessary... but I wish I had a way to automatically delete the session data when a user logs off. I have no idea as to how to do that... but if you have any suggestions, it would be much appreciated.

Another thing I realized is that there's no way to check who is currently logged in or how many people are currently logged in... because users that have logged off are in the same table as the users that are logged on. I'm thinking about just figuring out my own way to make a class that logs someone in and checks if they're logged in... but I don't really have any clever ideas as to how to go about doing that either. So, if you have any suggestions for that, please tell me. It would be much appreciated.

Reply With Quote
  #18  
Old January 7th, 2003, 06:06 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
For your first problem, you could use the OnUnLoad (i think thats it) function in your body tag. You would use that to force a small popup, when the user closes the browser.

In that popup window, you could then log them out and then close the window.

I would use a cron job to delete the session ids from the database. Make it run once a week, deleting all but the last 20 rows of the table.

Reply With Quote
  #19  
Old January 20th, 2003, 01:30 PM
Ole Moe Ole Moe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Hvidovre, Denmark
Posts: 2 Ole Moe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Missing SQL dump?

Missing SQL dump?
Hey All

Is it me or is there a missing sql dump to these articles?

By the way... I think they are very well written even for a non english speaking Dane. Keep up the good work.

In Denmark there is a saying: Hand out a lot of roses they might come back to you when you deserve them.

@;~~,~~'~~

Thank you...

le Moe

Reply With Quote
  #20  
Old January 22nd, 2003, 01:59 AM
evilcoder evilcoder is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 1 evilcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've noticed

global $strUser .. etc

what happens if register_globals is off?

Reply With Quote
  #21  
Old January 22nd, 2003, 07:59 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
then your buggered

Reply With Quote
  #22  
Old January 22nd, 2003, 08:22 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
So in most cases, if I have rented a hosting service this feature is turned on or off??? or it just depend on... Is it good to be on or off???

Last edited by wareseeker : January 23rd, 2003 at 08:11 AM.

Reply With Quote
  #23  
Old February 1st, 2003, 04:53 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
Ben Rowe - . .

Reply With Quote
  #24  
Old April 9th, 2003, 03:38 PM
r0ssr0ss r0ssr0ss is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 r0ssr0ss 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 r0ssr0ss Send a message via Yahoo to r0ssr0ss
help?

i followed your tutorial step by step religiously, and let me say its the best tutorial i've ever read, step by step.
i built my index page with the login form on it but when i view the page i get

Parse error: parse error, unexpected $end in c:\program files\apache group\apache\htdocs\docs\fc\index.php on line 219

i dont understand why?

heres the coding i used, i've looked over it a million times and cant seem to figure out what i did wrong, if someone could point me in the right direction that'd be awsome
in advance thx

My Code for index.php
and...
heres a picture of the files im using incase im missing something?

Last edited by r0ssr0ss : April 9th, 2003 at 03:45 PM.

Reply With Quote
  #25  
Old April 18th, 2003, 01:07 AM
r0ssr0ss r0ssr0ss is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 r0ssr0ss 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 r0ssr0ss Send a message via Yahoo to r0ssr0ss
wtf why wont anyone reply?

Reply With Quote
  #26  
Old April 18th, 2003, 01:22 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: 16
Im replying, what do you want help with?

Reply With Quote
  #27  
Old April 18th, 2003, 01:55 AM
r0ssr0ss r0ssr0ss is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 r0ssr0ss 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 r0ssr0ss Send a message via Yahoo to r0ssr0ss
read my above question

Reply With Quote
  #28  
Old April 18th, 2003, 02:00 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
the function
PHP Code:
function GetLogin()
            {

            
?> 
is missing the closing } at the end of it

Fix that and you will fix your problem

Reply With Quote
  #29  
Old April 18th, 2003, 06:47 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: 16
Well spotted Justin .

Reply With Quote
  #30  
Old April 18th, 2003, 10:45 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Thanks

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