want help in session and my quiz project
Posted: Wed Dec 23, 2009 12:32 am
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
can it work and not get fall in any case?
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?
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?
please give me the email sending code
you can check the website at
http://www.prevent-diseases.com/online
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.'">';
?>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?
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?
please give me the email sending code
you can check the website at
http://www.prevent-diseases.com/online