开发者

Share hidden values from one page to the next via a session

开发者 https://www.devze.com 2023-02-21 17:30 出处:网络
I have a some hidden values in one page. I want to create a session and 开发者_JS百科navigate with the hidden fields to the next page or another page and access the hidden values.

I have a some hidden values in one page. I want to create a session and 开发者_JS百科navigate with the hidden fields to the next page or another page and access the hidden values.

How can I do that? Please give me an example.


Try:

<form action="blah.php">
<input type="hidden" name="the_value" value="content" />

Then do the following in php:

<?
session_start(); // Start the session

$_SESSION['the_value'] = $_POST['the_value'];
?>

Now you have the value stored in the session. Be careful if you want to save this to MySQL. You need to sanitize the string first!

0

精彩评论

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

关注公众号