Hi all,
Relatively new to proper PHP coding (DW user -

) and have come unstuck. I'm passing a variable from a form (users enter their Postcode - ZIP code) and it's supposed to strip away any surplus characters before using that variable as a $_GET['x'] variable in the MySQL recordset. The problem I'm having, however, is that when I pass the variable ($pcsearch) from the 2nd page (convertpc.php - code below) I can't seem to get rid of the %20 and replace it with a space. Any help would be greatly appreciated.
CODE
//Split a postcode into two parts
$postcode = $_POST['postcode'];
$postcode2 = strtolower($_POST['postcode']);
if (!checkPostcode ($postcode2) ) {
echo 'Invalid postcode <br /> <a href="java script:history.back();">Back</a>';
}
else {
$postcodearray = explode(" ", $postcode);
$pcin = $postcodearray[0];
$pc2 = $postcodearray[1];
$pcout = $pc2[0];
$pcsearch = ($pcin." ".$pcout);
}
/* Redirect to a different page in the current directory that was requested */
$pcsearch = str_replace("%20", " ", $pcsearch);
$url = 'getresultsfromdatabase.php?postcode='.$pcsearch;
header("Location: ".$url);
exit();
*UPDATE --- I've just been sat thinking about this -- is there any way that I can just pass the variable $pcsearch directly to the search results page and, by calling this function on the search results page first, perform this function before anything else, thereby removing the need to use the header() function (which seems to be the thing causing me the headache

). If the function takes the variable as $_POST['postcode'] and outputs the result $pcsearch, how do I use $pcsearch in my SELECT statement?
Thanks very much for your help.
This post has been edited by jumbledup: 29 May, 2008 - 03:52 PM