now allow to change the value of variable
Moderator: General Moderators
now allow to change the value of variable
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?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Jcart | Please use
Jcart | Please use
Code: Select all
andCode: 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 pageCode: 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
andCode: 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]Run a MySQL query to check if the record exists before changing it.
Something along the lines of:
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
}