php variable transmission and js

Transfer: http://www.phpzixue.cn/detail759.shtml One. Forms passed when the form is submitted to a php script, the information from that form is automatically available to the script. Example: a simple HTML form [php] </ pre> <form> </ form> <pre> ion = "foo.php" method = "post"> Name: <input type = "text" name = "username "/> Email: <input type ="! text "name =" email "/> <input type =" submit "name =" submit "value =" Submit me "/> [/ php] there are many ways to access HTML data form. For example: Example: from a simple POST HTML form data access [php] <- php <br -> // php 4.1.0 starting from available print $ _POST [ 'username']; print $ _REQUEST.!?? [ 'username']; imp <wbr /> ort_request_variables ( 'p', 'p_'); print $ p_username; // php. 3 starting from available print $ HTTP_POST_VARS [ 'username']; // if register_globals = on command php available. But since // php 4.2.0 from the default value of register_globals = off. // Using / relying on this method. print $ username;?> [/ Php] Using a GET form is similar except you'll use the appropriate GET predefined variable. When submitting a form, an image may submit buttons instead of the standard, such a tag like: <input type = "image" src = "image.gif" name = "sub"> When the user clicks an image at the time, the appropriate form will be transferred to the server, and with two additional variables sub_x sub_y. They contain the user clicks on the image coordinates. Experienced users may notice that the actual variable names to be included in the browser sends a point rather than an underscore, but php automatically converted to underscore the point. two. Transmitting the URL <a href="test.php?id=3&name=mike"> next </a> available $ _GET [ 'id'] and $ _GET [ 'name'] GET to access data. three. Cookie transmission 1, a simple Set-Cookie: SetCookie ( "MyCookie", "Value of MyCookie"); with dead time: SetCookie ( "WithExpire", "Expire in 1 hour", time () + 3600); // 3600 s = 1 hour of everything: SetCookie ( "FullCookie", "Full cookie value", time () + 3600, "/ forum", ".phpuser.com", 1); if you want to set a plurality of the same name Cookie , use arrays, the method is: SetCookie ( "CookieArray [0]", "Value 1"); SetCookie ( " CookieArray [1] "," Value 2 "); 2, receiving and processing Cookie echo $ _COOKIE [ 'MyCookie']; echo $ _COOKIE [ 'CookieArray [0]']; echo count ($ _ COOKIE [ 'CookieArray']) ; 3, delete Cookie to delete an existing Cookie, there are two ways: First, call SetCookie with only the name argument, then known as the Cookie name will be deleted from the client relationship; the other is to set Cookie expiration time for the time () or time () - 1, then the Cookie after viewing all of this page has been deleted (in fact, ineffective) it should be noted that when a Cookie is deleted, it is. the value of Session passed test1.php [php] <session_start ()?; session_register ( "count"); echo $ count = 0;?> is still valid in the current page four. [/ php] test2.php [php] <? session_start (); echo $ count ++;?> [/ php] the study showed, php4 the session is valid only for the currently open browser window (at least in IE5 and NS6 under W2K is so) the following code. to achieve cross-session window to perform test1.php [php] <session_start ();.? session_ register ( "count"); setcookie ( "phpSESSID", session_id (), time () + 3600, "/", "www.md.hl.cn"); echo $ count = 0; <span style = "font -size: 0. value == '0') {document.logon.f_over_clk.value = '1'; document.logon.submit ();}}} //]]> </ script> </ pre> <form name = "logon "> </ form> <pre> ion =" logon_do.php "method =" post "> <a href="javas<wbr /> cript: logon_sub ();"> <img alt = "" src = ". ./img/LogonBt_iu.gif "name =" Logon "/> </a> <input type =" hidden "name =" mullang "value =" 0 "/> [/ php] can be used in page logon_do.php $ _POST [ 'mullang'] made this variables. six. An array of a plurality of pages can be transmitted between the array into a string, passed as a parameter: - file1.php [php] <... $ arg = implode ( ";", $ parm); $ link = "? ? file2.php arg = $ arg ";> [/ php] - file2.php [php] <$ parm = explode?? ("; ", $ arg); ...> [/ php]? submit ();}}} //]]> </> </ form> script> </ pre> <form name = "logon" <pre> ion = "logon_do.php" method = "post"> <a href = "javas <wbr /> cript: logon_sub ();"> <img alt = "" src = "../ img / LogonBt_iu.gif" name = "Logon" /> </a> <input type = " hidden "name =" mullang "value =" 0 "/> [/ php] in logon_do.php page can obtain the variables $ _POST [ 'mullang'] a. six. An array of a plurality of pages can be transmitted between the array into a string, passed as a parameter: - file1.php [php] <... $ arg = implode ( ";", $ parm); $ link = "? ? file2.php arg = $ arg ";> [/ php] - file2.php [php] <$ parm = explode?? ("; ", $ arg); ...> [/ php]? submit ();}}} //]]> </> </ form> script> </ pre> <form name = "logon" <pre> ion = "logon_do.php" method = "post"> <a href = "javas <wbr /> cript: logon_sub ();"> <img alt = "" src = "../ img / LogonBt_iu.gif" name = "Logon" /> </a> <input type = " hidden "name =" mullang "value =" 0 "/> [/ php] in logon_do.php page can obtain the variables $ _POST [ 'mullang'] a. six. An array of a plurality of pages can be transmitted between the array into a string, passed as a parameter: - file1.php [php] <... $ arg = implode ( ";", $ parm); $ link = "? ? file2.php arg = $ arg ";> [/ php] - file2.php [php] <$ parm = explode?? ("; ", $ arg); ...> [/ php]? php pages you can use $ _POST [ 'mullang'] made this variables. six. An array of a plurality of pages can be transmitted between the array into a string, passed as a parameter: - file1.php [php] <... $ arg = implode ( ";", $ parm); $ link = "? ? file2.php arg = $ arg ";> [/ php] - file2.php [php] <$ parm = explode?? ("; ", $ arg); ...> [/ php]? php pages you can use $ _POST [ 'mullang'] made this variables. six. An array of a plurality of pages can be transmitted between the array into a string, passed as a parameter: - file1.php [php] <... $ arg = implode ( ";", $ parm); $ link = "? ? file2.php arg = $ arg ";> [/ php] - file2.php [php] <$ parm = explode?? ("; ", $ arg); ...> [/ php]?

Reproduced in: https: //my.oschina.net/itfanr/blog/195629

Guess you like

Origin blog.csdn.net/weixin_34372728/article/details/91799490