want help in session and my quiz project

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mujaffar
Forum Newbie
Posts: 13
Joined: Tue Dec 22, 2009 11:16 pm

want help in session and my quiz project

Post by mujaffar »

hello

i have done a code in php and in that i done a session it is working and i have given time limit it is also working
but tell me it is correct method?
i have give code

Code: Select all

<?php session_start();?>
//checked username & password flag=0
<?php
if($flag==0)
{
 $_SESSION['username'] = $username;
 ?>
//then control go to the quiz page
//here i check
<?php
session_start();
?>
if(isset($_SESSION['username']))
{
//quiz code
?>
else
{
//redirect to another
}
//for logout
<?php 
session_start();
session_destroy();
?>
 
// i have given the session time as below
if(isset($_SESSION['username']))
{
   $user= strtolower ($_SESSION['username']);
// set timeout period in seconds
      $inactive = 600;
    // check to see if $_SESSION['timeout'] is set
      if(isset($_SESSION['timeout']) ) 
      {
      echo "in timeout";
      $session_life = time() - $_SESSION['timeout'];
      
       if($session_life > $inactive)
       { 
       echo $session_life;
       session_destroy(); 
       ?>
       <script language="javascript">
      window.location="./logout.php";
      </script>
      <?php
       }
      }
       
      $_SESSION['timeout'] = time();
    //  echo '<input type="text" name="life" value="'.$session_life.'">';
?>
can it work and not get fall in any case? :crazy:
Another problem i get in IE that when i am click on the back button or forward button from quiz_index to quiz then control goes to that page but page can not be found error is displayed why this happen?
:crazy:
i want to add a clock in project how should i add and how it display to page? after some time 2 hours i want to give control to another page how it done?
:idea:

please give me the email sending code
you can check the website at
http://www.prevent-diseases.com/online
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: want help in session and my quiz project

Post by Christopher »

Please use code tags. And ask one question at a time.

What specifically is not working in the code above? What have you tried to fix the problem?
(#10850)
mujaffar
Forum Newbie
Posts: 13
Joined: Tue Dec 22, 2009 11:16 pm

Re: want help in session and my quiz project

Post by mujaffar »

arborint wrote:Please use code tags. And ask one question at a time.

What specifically is not working in the code above? What have you tried to fix the problem?
problem i get in IE that when i am click on the back button or forward button from quiz_index to quiz then control goes to that page but page can not be found error is displayed why this happen?
:crazy:
Post Reply