Re: Re: Returning response includes HTML form data
| From: | brian | Date: | Sat, 02 Aug 2008 16:04:53 +0000 |
| Subject: | Re: Re: Returning response includes HTML form data | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277620@lists.php.net to get a copy of this message | ||
Edward Diener wrote:
Maciek Sokolewicz wrote:Because you haven't included any conditions to test whether or not to output the form, nor exited the script before the form is parsed. Pick one or the other. bEdward Diener wrote:Here is the code, with names suitable changed to protect actual functionality of proprietary software: ----------------------------------------------------------------------- <?php if ( ! (isset($_GET['zzzzz']) && $_GET['zzzzz'] == 124) ) {I have a PHP file which does an: echo "someresponse" to return some data. When I run it from a Windows client program, the response I am seeing is not only the "someresponse" above but also has the entire HTML form in the PHP file appended to it.?> <script> alert(" UnAuthorised Access.............."); window.location ="ascript.php"; </script> <?php echo " UnAuthorised Access.............."; exit;} function MyExampleFunction($param1, $param2, $param3,$param4="") {$param5 = 'Info1' . "\r\n"; $param5 .= 'Info2' . "\r\n"; $param5 .= 'Info3'; if(SomePHPFunction($param1,$param3,$param2."\r\n\r\n",$param5)) echo "SomePHPFunction called for $param1 OK.\n"; else echo "Could not call SomePHPFunction for $param1.\nError: ".$param4."\n";} if ($_FILES['AFileName']['name'] == "") {echo "No AFileName."; exit;} if ($_POST['AInput1'] == "") {echo "No AInput1."; exit;} if ($_POST['AInput2'] == "") {echo "No AInput2."; exit;} $AVariable1 = $_POST['AInput1']; $AVariable2 = $_POST['AInput2']; $size = filesize($_FILES['AFileName']['tmp_name']); $fp = fopen ($_FILES['AFileName']['tmp_name'], "r"); $AVariable3 = fread($fp, $size); fclose ($fp); @MyExampleFunction($AVariable1, $AVariable3, $AVariable2);?><form ENCTYPE="multipart/form-data" ACTION="" METHOD="POST"> <input NAME="AFileName" TYPE="file"> <input NAME="AInput1" TYPE="text"> <input NAME="AInput2" TYPE="text"> <input VALUE="submit" TYPE="submit"></form> ----------------------------------------------------------- The code takes to input fields and a single file upload, calls the MyExampleFunction, which calls the SomePHPFunction successfully. The SomePHPFunction is a function in one of PHP's libraries. The response comes from the: echo "SomePHPFunction called for $param1 OK.\n"; statement, plus <form ENCTYPE="multipart/form-data" ACTION="" METHOD="POST"> <input NAME="AFileName" TYPE="file"> <input NAME="AInput1" TYPE="text"> <input NAME="AInput2" TYPE="text"> <input VALUE="submit" TYPE="submit"></form> I have no idea why all the form data is being appended to the response.