简体   繁体   English

在页面之间移动表单数据的安全方法

[英]secure method to move form data between pages

I'm creating a form but I need to move data from form fields back and forth between pages. 我正在创建一个表单,但是我需要在页面之间来回移动表单字段中的数据。 I don't need to save the data after the page is submitted yet. 页面提交后,我不需要保存数据。

I know that I can use sessions (server side)and sql but I don't know which one is more secure or easier to implement and when I use sessions I can get the data to move forward on the pages but when I hit the back button it disappeared. 我知道我可以使用会话(服务器端)和sql,但是我不知道哪个更安全或更易于实现,当我使用会话时,我可以使数据在页面上前进,但是当我回击时按钮它消失了。

is one better than the other? 这个比那个好吗? Is there a way to use sessions to move data back and forth between form fields? 有没有一种方法可以使用会话在表单字段之间来回移动数据?
page 1 第1页

<?php
//startssession
session_start();
//datatostore
$_SESSION['post-data'] = $_POST;
$test1 = $_POST["test1"] ;
$test2 = $_POST["test2"] ;
$test3 = $_POST["test3"] ;
$email = $_POST["email"] ;
?>

page 2 第2页

<?php
// starts the session.
session_start();
// data to pull and display in test text box.
$test1 = $_POST["test1"] ;
$test2 = $_POST["test2"] ;
$test3 = $_POST["test3"] ;
$email = $_POST["email"] ;
?>

Use sessions 使用会议

when you hit the back button, that page probably does not have 当您单击“后退”按钮时,该页面可能没有

session_start();

If you do not have that then you will not be able to access the session data. 如果您没有,则将无法访问会话数据。

This is fairly secure for what you are doing but I would also insure you have SSL on your site when you go to production for another layer of security. 这对于您所做的工作来说是相当安全的,但是我还要确保在您进入生产环境以获取另一层安全性时,您的站点上具有SSL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM