<? 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 search
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: PHP search
So, what are you trying to do exactly? Give us an explanation of your objective.
Re: PHP search
You could put:
Which would return only the first half of the post code.
Or, if a space isn't required,
Code: Select all
$postcode = reset(explode(' ', $postcode));Or, if a space isn't required,
Code: Select all
$postcode = substr($postcode, 0, 3);-
tom_haire50
- Forum Newbie
- Posts: 5
- Joined: Mon Aug 10, 2009 11:28 am
Re: PHP search
Where would I insert that code?
Re: PHP search
No, you'd put it in the php script doing the processing.
Maybe you should take a look at some PHP tutorials...if you plan on having a PHP based website, I think you should at least know how it works. From what you've posted, this doesn't seem to be the case.
Maybe you should take a look at some PHP tutorials...if you plan on having a PHP based website, I think you should at least know how it works. From what you've posted, this doesn't seem to be the case.
Re: PHP search
No, you'd put it in the php script doing the processing.
Maybe you should take a look at some PHP tutorials...if you plan on having a PHP based website, I think you should at least know how it works. From what you've posted, this doesn't seem to be the case.
Maybe you should take a look at some PHP tutorials...if you plan on having a PHP based website, I think you should at least know how it works. From what you've posted, this doesn't seem to be the case.