[英]How can i send the values to the next page without the showing the values in the address bar
Here am sending a value month from a page to a php file named printall.php on clicking an image print.png. 这里是一个值页面从页面发送到一个名为printall.php的php文件,点击图片print.png。 I get that value in printall.php by using GET method. 我通过使用GET方法在printall.php中获得该值。 I find the value of of month displaying in the address bar of the window which opens printall.php on Clicking print.png. 我发现月份的值显示在窗口的地址栏中,该窗口在Clicking print.png上打开printall.php。
I want to hide or encode the value which displays in the address bar. 我想隐藏或编码地址栏中显示的值。 Is that anyone to help me out with this little doubt ? 有人帮我解决这个小疑问吗?
<a href="javascript:;" onclick="window.open('printall.php?id=<?php echo $month;?>');"><img src="print.png" width="25px" height="22px" style="border:0;" ></a>
You could create a form in the page that uses post and invisible fields. 您可以在页面中创建使用后期和不可见字段的表单。 Then using javascript then set the month on the invisible field and submit it. 然后使用javascript然后在隐形字段上设置月份并提交它。
Is $month the value of the current month, or is it based on user input? $ month是当月的值,还是基于用户输入? If it is the value of the current month, don't bother sending it to your PHP script, just use PHP's native datetime functions: 如果它是当前月份的值,请不要将其发送到您的PHP脚本,只需使用PHP的本机日期时间函数:
echo date('m'); // would echo 08 since current month is August
If $month is somehow based on user input, either of the other 2 answers would work, using AJAX or by submitting a form. 如果$ month以某种方式基于用户输入,则其他2个答案中的任何一个都可以使用AJAX或提交表单。
you can make POST submits with JavaScript; 你可以使用JavaScript提交POST; libraries like jQuery have nice Ajax utility functions. 像jQuery这样的库具有很好的Ajax实用功能。
PHP $_POST Function PHP $ _POST函数
The built-in $_POST function is used to collect values from a form sent with method="post". 内置的$ _POST函数用于从使用method =“post”发送的表单中收集值。
Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. 使用POST方法从表单发送的信息对其他人不可见,并且对要发送的信息量没有限制。
Note: However, there is an 8 Mb max size for the POST method, by default (can be changed by setting the post_max_size in the php.ini file). 注意:但是,默认情况下,POST方法的最大大小为8 Mb(可以通过在php.ini文件中设置post_max_size来更改)。
Ex. 防爆。
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
Url look like 网址看起来像
http://www.w3schools.com/welcome.php
Source: w3schools 资料来源:w3schools
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.