Page 1 of 1

now allow to change the value of variable

Posted: Sat Nov 05, 2005 12:03 pm
by rajan
i want to not allow the change the value of php variable when somebody refresh that page. how can this possible. i think it could be done using header but how can?

Posted: Sat Nov 05, 2005 12:17 pm
by Ambush Commander
Please define PHP Variable more clearly.

Posted: Sat Nov 05, 2005 1:31 pm
by rajan
suppose i have a varibale which will store in table when anybody refresh that page storing the variable in table will be again. how to prevent that

Posted: Sat Nov 05, 2005 1:32 pm
by John Cartwright
no idea what you are asking.. perhaps post some code along with a better explanation.

Posted: Sat Nov 05, 2005 1:47 pm
by rajan
Jcart | 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]


not whole but some piece of code given below. i do not want to insert the record when somebody referesh that page

Code: Select all

<? php
if(is_null($_SESSION[count1]))
	{
		echo "hello";
		if($count>0)
		{
			if($_POST[item_name.$i]=="1 hours" ||$_POST[item_name.$i]=="2 hours" || $_POST[item_name.$i]=="5 hours")
			{
			echo "<br> item is".$item."<br> quantity is".$quant ;
			$item1="Pre-paid Support";
			}
			else
			{
		//$sql="insert into acinfo(username,accounttype,purchased,used,txnid) values('$customer_email','$item','$quant','0','$txnid')";
			$sql="update acinfo set purchased=purchased+$quant,txnid='$txnid' where username='$_SESSION[user]' and accounttype='$item'";
		//echo $sql;
		$result=mysql_query($sql) or die(mysql_error());
			}	

		}
		else
		{
		$sql="insert into acinfo values('$_SESSION[user]','$item','$quant','0','$txnid')";
		$result=mysql_query($sql) or die(mysql_error());
		echo $sql;
		}
}
	if($item1=="Pre-paid Support")
			{
			//echo "<br> item is".$item."<br> quantity is".$quant ;
			//$item1="Pre-paid Support";
			$sql="update acinfo set purchased=purchased+
			$result=mysql_query($sql) or die(mysql_error());
			}
	
}
?>

Jcart | 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: Sat Nov 05, 2005 4:14 pm
by foobar
Run a MySQL query to check if the record exists before changing it.

Something along the lines of:

Code: Select all

$sql = 'SELECT somefield FROM sometable WHERE somecondition';
$rs = mysql_query($sql);
if (mysql_num_rows($rs)) {
  //oopsy daisy, that entry already exists
}

Posted: Sat Nov 05, 2005 4:33 pm
by rajan
i know that but i want to know how it can be done using headers.

Posted: Sat Nov 05, 2005 5:17 pm
by foobar
rajan wrote:i know that but i want to know how it can be done using headers.
Well, it bloody can't.