开发者

storing a TextBox value(in a html page) in php array variable which is then stored in a session

开发者 https://www.devze.com 2022-12-11 07:21 出处:网络
I am totally new to coding and i would need some help regarding this question of mine. the question is that,

I am totally new to coding and i would need some help regarding this question of mine. the question is that,

I have around 5 html pages.I am trying to wal开发者_开发问答k the user through each phase and thats the reason i have diffent page for entering the info.Each html page has certain text fields.For ex

Page1:lastname,firstname,mi...
Page2:address,phone,city,state,zip
Page3:date of join,time of joining,person who referred you
Page4:insurance info,insurance number
Page5:directions to the place, and so on.

Now the thing is that, i need to store the field values using sessions in php.

Suppose the user goes from page 1 to page 2(after filling all the details), and then if he wants to visit page 1,he should have all the fields populated with the data which he sent before(these details can be changed now).I want to store all the fields in a PHP array and then store the array using sessions.

My question is that how do we set the value of the php variable to the Value in the Textbox(the textbox will have the value entered by the user) and how do i design the array, and store it in the session.

Also can i use the same session variables across all the pages,so that i could save all the details entered by one particular in the array(which is then stored in the session).

Any help is greatly appreciated.


You can access the data passed to you in the $_GET and $_POST variables. eg

$lastname = $_POST['lastname'];

You can store the value away in a session like this...

session_start();  // call this once on your page
$_SESSION['lastname'] = $_POST['lastname'];

You could even do something like this...

// Store all the posted values in the session
$_SESSION['page1'] = $_POST;
0

精彩评论

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