1

I am having a lot of trouble with this, $report is breaking at the space in the URL, and I Have been trying to fix this problem for a couple of days now, and nothing is working.

<form onsubmit="return validate(this)" method="post" action=
    <?
         echo "\"reports1.php?report=";
         echo rawurlencode($report);
         echo "\"";
    ?>              
>

...

if(isset($_GET['report'])){
        $report = $_GET['report'];
        echo "<script>alert('All reports will be appended to \"".$report."\" until GET and POST data are cleared.')</script>";
    }
    elseif($country != NULL){
        $report = $date." ".$country." ".$topic;
    }

    elseif($country == NULL){
        $report = $date." ".$region." ".$topic;
    }

...

Here is an example; the $report is getting $_GET'ted as

"2011-05-08 ", even though it should be but it is $_POSTING as "2011-05-08 Brazil Botulism"
"reports1.php?report=2011-05-08 "

Ryan Ward Valverde
  • 6,458
  • 6
  • 37
  • 48

3 Answers3

4

urlencode() will work.

Make sure you wrap the address in quotes, and it is on one line:

<form ... action="reports1.php?report=2011-05-08%20Brazil%20Botulism">
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

Use PHP's trim() function to remove unwanted whitespace in the beginning and the end of a string.

abaumg
  • 2,083
  • 1
  • 16
  • 24
0

well you dont need to raw it,

echo "hi";

will work fine with ya, in case of ur code above there is only one problem that u use $_POST method for ur form not $_GET

form onsubmit="return validate(this)" method="post" action= should be

a very nice and easy debugin code that can help u is retriving all $_GETs and assign them to vars,

with

foreach($_GET as $var=>$val)$$var=$val;

this code wil get all posted gets and assign them to variables with there own name, ($report instead of $_GET['report'];) u can use this function on all $_post and $_get to know where is exactly the problem :)..

hope it helps

Zalaboza
  • 8,899
  • 16
  • 77
  • 142
  • Please use correct grammar and spelling while contributing to the site, thanks! – AJ. May 08 '11 at 21:38