简体   繁体   English

PHP何时使用get方法?

[英]php when to use get method?

how all, 全部

when is the right time to use $_GET['data']? 什么时候才是使用$ _GET ['data']的正确时间?

i want to pass value of userid from page A to page B by using popup javascript. 我想通过使用弹出JavaScript将用户ID的值从页面A传递到页面B。

    $qry="SELECT * FROM dbase WHERE id='".$id."'";
    $sql=mysql_query($qry);
    $rs=mysql_fetch_array($sql);

    <script language="JavaScript">
      function myPopup() {
        window.open( "<?=$CFG->wwwroot.'/ptk/main.php?task=ptk_checkapp&id='.$rs['userid'];?>" ,"myWindow", "status = 1, height = 500, width = 500, scrollbars=yes,toolbar=no,directories=no,location=no,menubar=no, resizable='yes';" )
     } 
    </script>

calling by hyperlink: 通过超链接调用:

<a href="#" onclick="myPopup()">
    <?=ucwords(strtolower($rs->nama));?>
</a>  

It seems that , the $rs['user'] dont hold any value on it. 似乎$ rs ['user']上没有任何值。 can tell me what problem or may be solution? 能告诉我什么问题或可能的解决方案?

thank you very much. 非常感谢你。

The $_GET superglobal is used to get parameters from the URL used to request the page. $_GET超全局变量用于从用于请求页面的URL中获取参数。 If you want to get a variable like http://site.com/page.php?variable=value then you would use $_GET['variable'] to get value . 如果您想获取类似http://site.com/page.php?variable=value的变量,则可以使用$_GET['variable']来获取value

This is very very unsecure code. 这是非常不安全的代码。 You will not want to use QueryStrings this way. 您将不希望以这种方式使用QueryStrings。 Anyway when you get the popup page, is the URL correct? 无论如何,当您获得弹出页面时,URL是否正确? meaning does it contain the id= value that you are expecting? 含义是否包含您期望的id =值? if it does the you may not be declaring 如果这样做,您可能没有声明

$id = $_GET('id'); 

which would be necessary. 这将是必要的。 http://www.owasp.org/index.php/Main_Page will get you going in the right direction for secure web app thinking. http://www.owasp.org/index.php/Main_Page将带您朝正确的方向前进,以进行安全的Web应用程序思考。

read about GET and POST in here and here 这里这里阅读有关GET和POST的信息

if you want to use javascript I suggest you to use framework like Jquery and any and post or get the data using AJAX way, it's better. 如果您想使用javascript,建议您使用Jquery之类的框架,并使用AJAX方式发布或获取数据,那会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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