我正在尝试使用以下代码更新基于另一个会话值($_SESSION['adtitle']
)的会话值($_SESSION['amount']
)。它适用于第一次页面加载,但之后它没有尽管我的主会话$_SESSION['amount']
正在更新
<?php
session_start();
if (isset($_SESSION['amount'])) {
if($_SESSION['amount']=2)
$_SESSION['adtitle']="Premium Listings for $2";
else if ($_SESSION['amount']=4)
{$_SESSION['adtitle']="Premium Blogs for $4";}
} else {
$_SESSION['adtitle']="Pls select your purchase type again!!";
}
header('Location: '. $_SERVER['HTTP_REFERER'] . '');
?>
答案 0 :(得分:0)
在比较中缺少=
。我已经解决了这个问题
<?php
session_start();
if (isset($_SESSION['amount'])) {
if($_SESSION['amount']==2)
$_SESSION['adtitle']="Premium Listings for $2";
else if ($_SESSION['amount']==4)
{$_SESSION['adtitle']="Premium Blogs for $4";}
} else {
$_SESSION['adtitle']="Pls select your purchase type again!!";
}
header('Location: '. $_SERVER['HTTP_REFERER'] . '');
?>