简体   繁体   English

在 HTML 页面之间共享数据

[英]Sharing data between HTML pages

I am kinf od new to the HTML relation and sharing stuff, I was wondering if I could share "large amount of data" between pages I have a HTML that rapresents a shop, and when I select multiple itmes to add to the cart I take the image of it, the name, the quantity and pricy Now, the question come obvious: How can I share all these informations from HTML pages using whatever is needed?我是 HTML 关系和共享内容的新手,我想知道我是否可以在页面之间共享“大量数据”它的图像、名称、数量和价格 现在,问题来了:如何使用所需的任何东西从 HTML 页面共享所有这些信息? (Such as PHP or JS) Can I do this in a separate pages? (如 PHP 或 JS)我可以在单独的页面中执行此操作吗? Can I share between pages, like, a that has into it like some other HTML components?我可以在页面之间共享吗,就像其他 HTML 组件一样?

I have looked for other solution that could help me but I found none我一直在寻找其他可以帮助我的解决方案,但我没有找到

I thank whoever come and help me, if there is already a solution that I haven't seen, I apologize for writing this我感谢任何来帮助我的人,如果已经有我没有看到的解决方案,我很抱歉写这个

You can use PHP and Session-Variables, that you fill with a HTML-Form.您可以使用 PHP 和 Session-Variables,用 HTML 表单填写。 For example a - form method="POST" - with a - input name ="name" action="index.php".例如 - 表单方法 =“POST” - 带有 - 输入名称 =“name” 操作 =“index.php”。


//PHP file //PHP文件

session_start(); session_start();

$_SESSION["name"] = $_POST["name"]; $_SESSION["name"] = $_POST["name"];

echo $_SESSION["name"];回声 $_SESSION["name"];


The $_SESSION["name"] will be available on any page (under the same domain); $_SESSION["name"] 将在任何页面上可用(在同一域下); The "session_start()." “session_start()”。 line has to be on top of every page in the php tag.行必须位于 php 标记中每一页的顶部。

Be sure so secure the string before working with MySQL.在使用 MySQL 之前,请确保将琴弦固定好。

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

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