How do I keep a URL from breaking at the spaces? No method is working
I am having a lot of trouble with this, $r开发者_开发问答eport 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 "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">
Use PHP's trim()
function to remove unwanted whitespace in the beginning and the end of a string.
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
精彩评论