SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 28th, 2002, 04:22 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
session help

I'm making a survey for a site and the first page is a login page. The person has to enter in an id number and we check to make sure it is in our database. I just want to make sure that people cannot hotlink past that page and take the survey without using this id number. I am passing it from page to page in session variables but I'm kind of new with sessions. How do I require that the ID number was entered on the first page. Also can any see any other issues were people can skew results? Thanks

Reply With Quote
  #2  
Old August 28th, 2002, 05:03 PM
Taoism Taoism is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Winnipeg, MB, Canada
Posts: 81 Taoism User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 sec
Reputation Power: 2
RE: session help

I have a multi-page wizard that I don't want people to jump into the middle of, so my solution was simple:

php Code:
Original - php Code
  1.  
  2. <?php
  3. /**
  4. * function to check for the existence of required session variables.  It will redirect
  5. * to an error page if the session variables are not set
  6. *
  7. * @author Keith Young <youngka@agr.gc.ca>
  8. * @since 08-Jul-2002
  9. * @version 1.0
  10. *
  11. * @global array $XFA exit fuseaction array used for redirect
  12. *
  13. */
  14. function sess_redirect(){
  15.   global $XFA;
  16.  
  17.   //this check will help to avoid DB errors being displayed if the user lets the session time out.
  18.   if(!isset($_SESSION['rt']['wizpage1']['prov'])||!isset($_SESSION['rt']['wizpage1']['claim_yr'])){
  19.     header('Location: index.php?fuseaction='.$XFA['sesserr']);
  20.   } 
  21. }//end sess_redirect()
  22. ?>


Hope it helps!

Cheers,
Keith.

Reply With Quote
  #3  
Old August 28th, 2002, 05:36 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: session help

hi taoism can u explain how that works?

what is all that rt, wizpage1, stuff beside SESSIONS? and how is there an array with sesser... that looks confusing ... how does it check every middle page the user goes to , to see if he's logged in?

Reply With Quote
  #4  
Old August 28th, 2002, 05:49 PM
Taoism Taoism is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Winnipeg, MB, Canada
Posts: 81 Taoism User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 sec
Reputation Power: 2
RE: session help

Ahhh, well, I didn't write it for the poster... I wrote it for my application, so it reflects some of the array structure I store in the session variable.

To break it down in a simpler fashion...

The poster needs to check the $_SESSION variable for the existence of an id number... in order to prevent someone from jumping into page3.php instead of going to page1.php and entering a valid id you check for the variable in $_SESSION on every page past the first page...

So, to redo my function a touch....

php Code:
Original - php Code
  1.  
  2. <?php
  3. /**
  4. * function to check for the existence of
  5. * required a session variable. 
  6. * It will redirect to the survey id
  7. * enter page if it isn't found.
  8. *
  9. * @author Keith Young <youngka@agr.gc.ca>
  10. * @since 28-Aug-2002
  11. * @version 1.0
  12. *
  13. */
  14. function survey_redirect(){
  15.  
  16.   if(!isset($_SESSION['survey_id'])){
  17.     //use the err to display a message specifying they
  18.     //need to enter a survey id before proceeding
  19.     header('Location: survey_enter_id_page.php?err=1');
  20.   } 
  21. }//end sess_redirect()
  22. ?>


better?

Sorry, I didn't think the first was so confusing, or I wouldn't have posted it like it is..

Cheers,
Keith.

Reply With Quote
  #5  
Old August 28th, 2002, 05:59 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
RE: session help

Thanks. I'm now completely comfortable with the session stuff yet so your help was appreciated.

Reply With Quote
  #6  
Old August 28th, 2002, 06:10 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
RE: session help

that was supposed to be "not completely comfortable" instead of "now completely comfortable." HAHA I might want to read want I wrote before I post it.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > session help


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway