views:

46

answers:

2

Hello,

For the code below, I would like to append echo $_SERVER['QUERY_STRING']; to the end of index.php. But when I try to do it, it makes the code return a blank page. So I think I might be doing it wrong.

How can I correctly make this appendage?

Thanks in advance,

John

    <?php

    function show_loginform($disabled = false)
    {

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

    ...

    ?>
A: 

What about:

echo '<form name="login-form" id="login-form" method="post" action="./index.php?'.$_SERVER['QUERY_STRING'].'">';
webbiedave
Just to add to this answer, a very common mistake is to assume that $_SERVER['QUERY_STRING'] contains the question mark as well the query string. Actually, you must add in the question mark manually, as webbiedave has done.
Rupert
This works unless his blank-page is caused by a PHP error and not a 404
webdestroya
@webdestroya : OP's question implies that the page blankness is caused when attempting to append the query string. This answer shows him how to do it correctly. If other problems are found to exist, he can post a different question.
webbiedave
A: 

hmmmm. Can you spell XSS?

I'd recommend going with this is a more 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'>";
symcbean