question about session
Posted: Thu Oct 27, 2005 3:12 pm
is is possible that session value will have to be null without making it null in many post of same form. i did not understand why my session value is null in previos post.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php //for only showing on forum
<? session_start(); ?>
<? include_once('../include/mysql_connect.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:hover {
color: #FFFFFF;
}
a:active {
color: #FFFFFF;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12;
font-weight: bold;
}
-->
</style></head>
<body>
<?
if(isset($_GET['finaltime']))
{
/* echo "\n accountype".$_GET['accountype'];
echo "<br>Time Left".$_GET['minute'];
echo "<br>Start Time".$_GET['starttime']; */
$quantity1=$_GET['quantity1'];
$acc1=$_GET['accountype'];
$finalt=$_GET['minute']; //final time after account is used
$startt=$_GET['starttime']; //final time after account is start
$usedt=$finalt-$startt;
if($usedt<=10) //if time used is less the 10 minute
{
$updatet=$finalt-10; //final time left
}
else
{
$updatet=$finalt;
}
if($updatet==0)
{
if($quantity1>1)
{
$sql="update acinfo set quantity=quantity-1 where accounttype='$acc1' and username='$_SESSION[email]'";
}
else
{
$sql="delete from acinfo where accounttype='$acc1' and username='$_SESSION[email]'";
}
}
else
{
$sql="update acinfo set minute='$updatet' where accounttype='$acc1' and username='$_SESSION[email]'";
}
$result=mysql_query($sql) or die(mysql_error());
}
if(isset($_POST['prosel']))
{
$acctype=$_POST['radiobutton'];
$sql="select minute,quantity from acinfo where accounttype='$acctype' and username='$_SESSION[email]'";
$result=mysql_query($sql)or die(mysql_error());
$row=mysql_fetch_row($result)or die(mysql_error());
$minute=$row[0];
$quantity=$row[1];
if($minute==0)
{
if($quantity==1)
{
$query="delete from acinfo where accounttype='$acctype' and username='$_SESSION[email]'";
}
else
{
$query="update acinfo set quantity=quantity-1 where accounttype='$acctype' and username='$_SESSION[email]'";
}
$result=mysql_query($query)or die(mysql_error());
?>
Account is modified </p>
</div>
<span class="style1">
<?
}
else
{
?>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = '<? echo $minute ?>'*60
StartTheTimer()
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
var finaltime=true
alert('<? echo $acctype ?>');
var acctype='<? echo $acctype; ?>'
var starttime='<? echo $minute; ?>'
var quantity1='<? echo $quantity ?>'
var minute= Math.round(secs/60);
alert(minute)
<? echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
. "&minute=\" + minute + \"&finaltime=\"+finaltime+\"&accountype=\" + acctype + \"&starttime=\"+starttime + \"&quantity1=\"+quantity1;\n"; ?>
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
// Here's where you put something useful that's
// supposed to happen after the allotted time.
// For example, you could display a message:
alert("You have just wasted 10 seconds of your life.")
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
InitializeTimer()
//-->
</SCRIPT>
<?
}
}
?>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="style1"> </td>
</tr>
<tr>
<td class="style1"> </td>
</tr>
<tr>
<td class="style1">Please Enter the Email Address of Customer </td>
</tr>
<tr>
<td class="style1"> </td>
</tr>
<tr>
<td class="style1"></td>
</tr>
<tr>
<td class="style1"><table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>Email Address </td>
<td><form name="form1" method="post" action="<? echo $_SERVER['PHP_SELF'] ?>">
<input type="textfield" name="txtEmail">
</form></td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="hid" type="hidden" value="TRUE">
<input type="submit" name="emailsubmit" value="Submit">
</td>
</tr>
</table></td>
</tr>
</table>
<p class="style1"> </p>
<span class="style1">
<?
if(isset($_POST['hid']) or isset($_SESSION['email']))
{
$email=$_POST['txtEmail'];
if(!is_null($email))
{
$_SESSION['email']=$email;
}
?>
<? $_SESSION[email]="ashuraj2163@rediffmail.com"; ?>
<table border="1" align="center" cellpadding="1" cellspacing="1">
<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post" class="style1">
<tr align="center">
<td>Account holder Id </td>
<td><? echo $_SESSION['email'] ?> </td>
<td> </td>
<td><input name="stoptimer" type="button" id="stoptimer" value="stop timer" onClick="StopTheClock()"></td>
</tr>
<tr align="center">
<td>Account Type </td>
<td>Minute</td>
<td>Quantity</td>
<td>Select Account</td>
</tr>
<?
$sql="select * from acinfo where username='$_SESSION[email]'";
$result=mysql_query($sql)or die("database fetch error".mysql_error());
while($row=mysql_fetch_assoc($result))
{
?>
<tr align="center">
<td><? echo $row['accounttype'] ?></td>
<td><? echo $row['minute'] ?> of current account</td>
<td><? echo $row['quantity'] ?> </td>
<td><input name="radiobutton" type="radio" value="<? echo $row['accounttype'] ?>" checked></td>
</tr>
<?
} ?>
<tr align="center">
<td colspan="4"><input type="submit" name="Submit" value="Submit">
</td>
</tr>
<input name="prosel" type="hidden" value="TRUE">
</form>
</table>
<p class="style1"> </p>
<?
}
?><p> </p>
</TD>
</TR>
<TR>
<TD height="1" width="12"> </TD>
<TD height="1" width="10"> </TD>
<TD height="1" width="5"> </TD>
<TD height="1" width="84"> </TD>
<TD height="1" width="5"> </TD>
<TD height="1" width="27"> </TD>
<TD height="1" width="15"> </TD>
<TD height="1" width="9"> </TD>
<TD height="1" width="18"> </TD>
<TD height="1" width="11"> </TD>
<TD height="1" width="9"> </TD>
<TD height="1" width="5"> </TD>
<TD height="1" width="89"> </TD>
<TD height="1" width="7"> </TD>
<TD height="1" width="88"> </TD>
<TD height="1" width="5"> </TD>
<TD height="1" width="89"> </TD>
<TD height="1" width="6"> </TD>
<TD height="1" width="88"> </TD>
<TD height="1" width="6"> </TD>
<TD height="1" width="46"> </TD>
<TD height="1" width="10"> </TD>
<TD height="1" width="33"> </TD>
<TD height="1" width="5"> </TD>
<TD height="1" width="93"> </TD>
<TD height="1" width="3"> </TD>
<TD height="1" width="11"> </TD>
<TD height="1" width="11"> </TD>
<TD height="1" width="4"> </TD>
</TR>
</TABLE>
<p align="center"><b><font face="Verdana" color="#000000" size="1">Copyright: All Right Reserved-2005. LivePCdoctor.com, Website designed & maintained by: <a href="../../wintech%20webdesign.html" target="_blank" style="text-decoration: none; color: #FFFFFF"><font color="#000000">WinTech Webdesign.</font></a></font></b></p>
</div>
</body>
</html>
// for only showing on forum ?>Code: Select all
tags when [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting PHP Code In The Forums[/url][/size]