tags:

views:

48

answers:

3

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.

+2  A: 

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.

webdestroya
+2  A: 

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.

Gabriel
+1  A: 

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.

Nazmin
Better depends on what you are wanting to do. If that's the only javascript that the OP will be using then there's no reason to use a JS framework.
Blair McMillan
agreed, I am always tempted to rely heavily on the frameworks because I use them for almost every project, but we should resist the temptation to believe it is the right tool for every job.
Gabriel
yeah, i think that the best way is to keep ourself up to date in every way comes ahead, why have to use traditional way if there's a new and advance way...but it's not harm to do both though, plus its good to try a new things in a small range so that we could learn faster...
Nazmin
Nazmin, great point. If you are new and javascript is a little scary picking up a framework and learning the fast way is going to improve your productivity and ease your curve. Besides, jQuery rocks.
Gabriel