GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Aug-2004, 22:19
badronald badronald is offline
New Member
 
Join Date: Aug 2004
Posts: 1
badronald is on a distinguished road

Login Page troubles


Hello
I am new here and new to PHP and MYSQL. I have created a working (phew) login page that authenticates users via php and a mysql database. Now what I am trying to figure out is I have a multi page questionnaire, if they exit and return how they can return to the same place they left or if they finish the questionnaire they cannot login again (and instead get a message saying the already finished it). Using cookies or session variables is ok but I can find no info on this anywhere!!! The date they answer on the questionnaire is stored in a seperate MYSQL database so I guess the 2 need to be linked (joined?) Thanks!
  #2  
Old 04-Aug-2004, 09:59
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello badronald,

I have not done something similar to be honest, but I did think about this for a while and here's what I would suggest:

Set a cookie named for example 'questionnaires'. Inside it, you could have the following sample array:

PHP Code:

<?php
$_COOKIE['questionnaire']['john'] =
  array(
    6=>array(  // 6 is the questionnaire ID
         1=>'a',  // 1 - 5 below is the question ID as key
         2=>3754, // and the answers as value
         3=>true,
         4=>42,
         5=>'a,b,d',
         'np'=>2  // the next page off the questionnaire, if value is null, the questionnaire was done
       )
  );
?>


Looking at the example data above, you (your script) can easily match the $_SESSION['user_name'] (if john is logged in, it would be 'john') to match it with the $_COOKIE['questionnaire']['john'], i.e. if( isset($_COOKIE['questionnaire'][$_SESSION['user_name']]) ). If it's a match, you can load the array $_COOKIE['questionnaire']['john'] into your script and do the necessary.

Added: you need to serialize( $_COOKIE['questionnaires'] ); before you set the cookie, and unserialize( $_COOKIE['questionnaires'] ); before you work on it in your scripts...
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Error on Search page BobbyDouglas GIDForums™ 4 28-Jul-2004 17:35
What's wrong with this page? Socrates Demise Websites Reviewed Forum 2 31-Mar-2004 10:50
simple form from generated page zuzupus Web Design Forum 0 17-Sep-2003 10:27
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 21:10
Search Engine Positioning 101 and 201 "How To" Tips... 000 Search Engine Optimization Forum 0 29-May-2003 11:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:25.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.