开发者

how to add the values stored in a session variable in php?

Okay

I have two pages-- page1.php and page2.php .Both of these pages have select lists.I have posted the values selected by the user to script.php which has them stored in session variables.

I need to add the values (which are the ones selected by the user from the select lists in both the pages) and display this total value in page3.php.now how do i add these values in the script?

开发者_开发技巧

any suggestions would be helpful.thanks in advance.


If I get your problem correctly, you can just fetch values directly from $_SESSION variable:

$total = $_SESSION['value1'] + $_SESSION['value2'];

Of course you should also check if the session variables are set at all and are correct (numeric). The $_SESSION (and not $_session!) is one of the "superglobal" variables in PHP - read more.


$_session['var1] + $_session['var2']

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜