简体   繁体   中英

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. I get that value in printall.php by using GET method. I find the value of of month displaying in the address bar of the window which opens printall.php on Clicking print.png.

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.

Is $month the value of the current month, or is it based on user input? 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:

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.

you can make POST submits with JavaScript; libraries like jQuery have nice Ajax utility functions.

PHP $_POST Function

The built-in $_POST function is used to collect values from a form sent with 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.

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).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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