Adding a query string to the end of a function action url

In the below code, I would like to add echo $_SERVER['QUERY_STRING'];

to the end of index.php. But when I try to do this, it makes the code return a blank page. So I think I am wrong.

How can I make this appendage right?

Thanks in advance,

John

    <?php

    function show_loginform($disabled = false)
    {

        echo '<form name="login-form" id="login-form" method="post" action="./index.php"> 

    ...

    ?>

      

+2


a source to share


2 answers


What about:



echo '<form name="login-form" id="login-form" method="post" action="./index.php?'.$_SERVER['QUERY_STRING'].'">';

      

+1


a source


hmmm. Can you write XSS?

I would recommend this to be the safer option:



$url='./index.php';
$qry=array();
$join='';
foreach ($_GET as $name=>$val) {
   $join='?';
   $qry[]=urlencode($name) . '=' . urlencode($val);
}
$url.=$join . implode('&',$qry);
print "<....action='$url'>";

      

+1


a source







All Articles