PHP search
Posted: Mon Aug 10, 2009 11:32 am
<? include("includes/header.php"); ?>
<?php
$handle = file_get_contents("Postcodes.txt",NULL);
$submit=$_POST['Submit'];
$a =$_POST['Postcode'];
$a=str_replace(",","",$a);
$a=explode(" ",$a);
$c=0;
foreach($a as $y){
if (stristr($handle,"$a[$c]")) $b[]= 'yes';
else $b[]='no';
$c++;
}
if (in_array("yes",$b)) header("Refresh: 0; url=yourArea.html?i=idx");
else header("Refresh: 0; url=NotsYourArea.html?i=idx");
?>
The above code works by checking a text file with the first part of postcodes e.g TS1, TS2. If the postcode is there it forwards one page else it forwards another. I want the user to be able to enter there full postcode e.g TS1 4AA but it only needs to check the first part. It looks more professional if the user enters there full postcode, but will still only use the first part.
<?php
$handle = file_get_contents("Postcodes.txt",NULL);
$submit=$_POST['Submit'];
$a =$_POST['Postcode'];
$a=str_replace(",","",$a);
$a=explode(" ",$a);
$c=0;
foreach($a as $y){
if (stristr($handle,"$a[$c]")) $b[]= 'yes';
else $b[]='no';
$c++;
}
if (in_array("yes",$b)) header("Refresh: 0; url=yourArea.html?i=idx");
else header("Refresh: 0; url=NotsYourArea.html?i=idx");
?>
The above code works by checking a text file with the first part of postcodes e.g TS1, TS2. If the postcode is there it forwards one page else it forwards another. I want the user to be able to enter there full postcode e.g TS1 4AA but it only needs to check the first part. It looks more professional if the user enters there full postcode, but will still only use the first part.