简体   繁体   中英

php when to use get method?

how all,

when is the right time to use $_GET['data']?

i want to pass value of userid from page A to page B by using popup javascript.

    $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. 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. If you want to get a variable like http://site.com/page.php?variable=value then you would use $_GET['variable'] to get value .

This is very very unsecure code. You will not want to use QueryStrings this way. Anyway when you get the popup page, is the URL correct? meaning does it contain the id= value that you are expecting? 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.

read about GET and POST in here and here

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.

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