[英]Not able to encode and decode Url in php
I have created a form and passing dynamic information to the next page through URL. 我已经创建了一个表单,并将动态信息通过URL传递到下一页。
edit_user.php edit_user.php
<form class="w3-container " action='edit_action.php?edit_id=<?php echo $edit_id ?>' method='post' name="form" id="form-e" role="form">
URL view: http://localhost/gst_work/bank/edit_user.php?edit_id=64 网址检视: http://localhost/gst_work/bank/edit_user.php?edit_id = 64
I'm trying to encode Url by urlencode() function to secure data 我正在尝试通过urlencode()函数对Url进行编码以保护数据
below code 下面的代码
<form class="w3-container " action='urlencode(edit_action.php?edit_id=<?php echo $edit_id); ?>' method='post' name="form" id="form-e" role="form">
this return semicolon error every time. 每次返回分号错误。
i also want to get this url value in next page ie edit_action.php page. 我也想在下一页即edit_action.php页面中获得此url值。 how this can be achieved with decodeurl() function, right now i'm directly using $_GET['edit_id'] method.
现在如何直接使用$ _GET ['edit_id']方法来实现如何使用encodeurl()函数实现此目的。
And what can be different ways for handling and securing URL data in php apart from encodeurl or session ? 除了encodeurl或session,还有什么其他方法可以用来处理和保护PHP中的URL数据?
Your syntax is wrong. 您的语法错误。 This is the correct syntax
这是正确的语法
<form class="w3-container " action='edit_action.php?edit_id=<?= urlencode($edit_id); ?>' method='post' name="form" id="form-e" role="form">
urlencode
is a PHP function and should be within the PHP tags. urlencode
是一个PHP函数,应位于PHP标记内。
To access the edit_id
parameter in edit_action.php
, use a filtering function like filter_input()
and do avoid accessing superglobal arrays like $_GET
and $_POST
directly. 要访问
edit_id
参数在edit_action.php
,使用像滤波功能filter_input()
和不避免访问超全局数组像$_GET
和$_POST
直接。
In your case, filter_input(INPUT_POST, 'edit_id');
就您而言,
filter_input(INPUT_POST, 'edit_id');
since you have the form method set as post. 因为您将form方法设置为post。
为什么要编码整个url,只需要编码要传递的值
<form class="w3-container " action='edit_action.php?edit_id=<?php echo urlencode($edit_id); ?>' method='post' name="form" id="form-e" role="form">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.