Page 1 of 1

different behavior of program in local and main website

Posted: Wed Oct 26, 2005 3:38 pm
by rajan
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


i have made a progrm that not works properly in website but when we use this on website it does not display any thing when i click on use account button .

on the start of page

Code: Select all

<? session_start(); ?>
<? include_once('../include/mysql_connect.php'); ?>
<? ob_start(); ?>

<? php
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;
//echo "finalt".$finalt;
//echo "<br>startt".$startt;
	if($usedt<=10) //if time used is less the 10 minute
		{
		//echo "time less then 10 minute";
		$updatet=$finalt-10; //final time left
		//echo "updatet".$updatet;
		//echo "<br>usedt".$usedt;
		}
		else
		{
		$updatet=$finalt;
		}
			if($updatet<=0)
			{
				if($quantity1>1)
				{
				switch($acc1)
				{
				case "1 hours" :
				$t=60;
				break;
				case "2 hours" :
				$t=120;
				break;
				case "5 hours" :
				$t=300;
				break;
				default:
				$t=0;
				}
				//echo "time is ".$t;
				//echo "accoun type is".$acc1;
					if($t==0)
					$sql="update acinfo set quantity=quantity-1 where accounttype='$acc1' and username='$_SESSION[email]'";
					else
					$sql="update acinfo set quantity=quantity-1, minute='$t' 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'";
$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("Watch the status bar to see the clock")
	<? 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("Your account has been finished")
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
InitializeTimer()
//-->
        </SCRIPT>
        <?

   }
}   
?>
        </span>
        <table border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="style1">&nbsp;</td>
          </tr>
          <tr>
            <td class="style1">&nbsp;</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">
                  </td>
                </tr>
                <tr>
                  <td colspan="2" align="center">
                    <input name="hid" type="hidden" value="TRUE">
                    <input type="submit" name="emailsubmit" value="Submit">
                  </td>
				  </form>
                </tr>
            </table></td>
          </tr>
        </table>
        <p class="style1">&nbsp;</p>
        <span class="style1">
        <?
  	if(isset($_POST['hid']) or isset($_SESSION['email']))
	{	
	$email=$_POST['txtEmail'];
	$query="select password from customer where username='$email'";
	$result=mysql_query($query);
	$password=mysql_fetch_row($result);
	$_SESSION['password']=$password[0]; 
	if(!is_null($email))
	{
	$_SESSION['email']=$email; 
	}
	
?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Wed Oct 26, 2005 4:11 pm
by shiznatix
please edit your post with php tags so we can read it and help you out

Posted: Thu Oct 27, 2005 4:49 am
by Jenk
You need to either remove the ob_start() at the top, or add ob_end_flush() at the end of your script.

solution is not woking kindly urgent help

Posted: Thu Oct 27, 2005 1:46 pm
by rajan
solution given by jenk is not working

when i click any button , information is lost

Posted: Thu Oct 27, 2005 2:02 pm
by shiznatix
where is you $_GET coming from? i don't see that being set anywhere. the only thing that your form will do is set a $_SESSION if and only if you have that email in your db. there is nothing that is going to trigger the rest of your code

Posted: Thu Oct 27, 2005 2:07 pm
by rajan
$_get is comming from javascript's location.href

Posted: Thu Oct 27, 2005 2:10 pm
by rajan
i also notice my from session variable $_SESSION[email] has been lost and my database is also not updated