English 中文(简体)
将数据保存到 PHP 中的另一页
原标题:POSTING data to another page in PHP

我正在做一些工作,让用户编辑他们提交的表格,我有两个问题。

  1. 在页面查看格式.php上说, 编辑表格的页面是编辑格式.php。 是否安全通过窗体 s ID, 然后使用 Get 。 我会验证试图在编辑格式上访问的人。 php 是使用连接用户名的会话 ID 创建它的人, 设置在登录时 。

  2. 如果 1 不是安全的方法, IPOST 数据( 使用提交按钮) 如何从视图格式.php 到编辑格式.php?

最佳回答

当然,$$_GET 是安全的,只要没有任何敏感数据传输。ID是常用的

问题回答

如果我正确理解您的问题, 您正在寻找的是如何在使用表格的请求中坚持数据 。 因为这样您就可以在动作属性中指定一个以窗体表示的提交 URL, 您可以通过请求对象从该 URL 访问窗体的值。 如果将您的数据提交到同一页, 您可以使用 $_SERV[ PHP_ SELF], 该页面包含您正在使用的页面的引用。 因此, 为了回答您的问题, 您的视图格式.php 将会有 :

<form action="editform.php">
<input type="text" name="inputvariable" />
<input type="submit" value="Go" />
</form>

在编辑格式.php 中,您可以通过访问 $_REQUEST [输入变量] 访问可输入的数值

希望这能帮上忙

为什么不设置向 POST 提交表格的方法 。 使用 Get 可能导致某人修改页面的 URL 并插入可能对您网站产生某些不理想影响的数据 。

如果使用 POST, 在接收数据时, 将变量设置为此

$var1 = $_POST[ variable1 ];

您可以在 $_SESSION 数组中保存 Id, 然后将您从 URL 获得的 ID 与 您在 $_SESSION 中保存的 id 匹配。 如果它们不匹配, 您可以显示错误信息 。 这将防止您的网站在有人更改 URL 时出现不理想的行为 。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签