Project Description:
When someone goes to [login to view URL] and clicks "Go" we need a php script to run and do the follow: Note that this may look long but its a fairly simple script with a bunch of if statements.
A quick intoduction about the website, the website currently uses a web form to collect input data for field variables and submits that data to a php file. This will be futher discussed later.
The following variables have input variables: email, phone, item, pricemin, pricemax, zip, miles, vmake, vmodel, minmileage, maxmileage, year, carseller, doors, propertytype, city, state, homesller, minacres, maxacres, minsqfeet, maxsqfeet, minbedrooms, maxbedrooms, carsearch, homesearch
Note that if the user doesn't fill in a variable then it has a default value of "". Unless otherwise directed, you do not need to check if a variable has a value.
-First once a user clicks "Go", the webpage needs to expand (like according style) with a message that says "Processing....". Preferably with the dots moving or some type of animation. Ex. "." -> ".." -> "..." -> "...." -> "." -> ".." etc.
- If the zip code (5 digits) starts will "45xxx" then
-Then take the values from "item" "pricemin" and "pricemax" and substitute them into the following url. Note "{variable}" should be filled in with the value. The brackets should not be included in the url
- [login to view URL]{item}&srchType=A&minAsk={pricemin}&maxAsk={pricemax}
- Read the number of listing (classified advertisements) for the LAST 7 DAYS and return that number.
- If the zip code (5 digits) starts will "65xxx" then
-Then take the values from "item" "pricemin" and "pricemax" and substitute them into the following url. Note "{variable}" should be filled in with the value. The brackets should not be included in the url
- [login to view URL]{item}&srchType=A&minAsk={pricemin}&maxAsk={pricemax}
- Read the number of listing (classified advertisements) for the LAST 7 DAYS and return that number.
- For all other zip code then
-The script need to look at the values of "carsearch" and "homesearch" and do the following based on the values:
- If both values are blank (I.e. "") then:
-Take the values from "item", "pricemin", "pricemax", "zip", "miles" and put them in the following url:
- [login to view URL]{item}&zip={zip}&distance={miles}&min_price={pricemin}&max_price={pricemax}&addisplay=%5BNOW-7DAYS+TO+NOW%5D&sort=5&nocache=1&viewNumResults=1&sort=5
-Read the number of pages of results and return that number (a value in the url sets it so only listings for the last 7 days are shwon).
- If "homesearch" is True then:
- If multiple cites are entered, repeat this process for each city. Note that if multiple cites are entered, they will be separated by a comma
-Change the propertytype from the given value to the following:
- if propertytype=='apartment':
propertytype='277'
if propertytype=='singlefamily':
propertytype='279'
if propertytype=='townhome':
propertytype='355'
if propertytype=='manufactured':
propertytype='357'
if propertytype=='horse':
propertytype='339'
if propertytype=='vacation':
propertytype='354'
if propertytype=='multi':
propertytype='672'
-Change the homeseller from the given value to the following:
- if homeseller=='agent':
homeseller='1'
if homeseller=='owner':
homeseller='0'
-Take the values from "item", "pricemin", "pricemax", "zip", "miles", "propertytype", "city", "state", "homesller", "minacres", "maxacres", "minsqfeet", "maxsqfeet", "minbedrooms" and put them in the following url:
- [login to view URL]"city"&zipcode="zip"&distance="miles"&state="state"&start="pricemin"&end="pricemax"&keyword="item"&sellertype="homeseller"&acresstart="minacres"&acresend="maxacres"&sqftstart="minsqfeet"&sqftend="maxsqfeet"&bedrooms="minbedrooms"&homes_search=Search
- Read the number of listing (classified advertisements) for the LAST 7 DAYS and return that number. If multiple cites were given, then return the total number of listings
- If "carsearch" is True then:
- Take the values from "pricemin", "pricemax", "vmake", "vmodel", "minmileage", "maxmileage", "year", "carseller", "doors" and enter them into the Javascript code at:
- [login to view URL]
- Read the number of listing (classified advertisements) for the LAST 7 DAYS
- Then based on the value for "miles" do the follow:
- If miles=="5":
number_of_listings=.1*number_of_listings
If miles=="10":
number_of_listings=.2*number_of_listings
- If miles=="25":
number_of_listings=.35*number_of_listings
If miles=="50":
number_of_listings=.7*number_of_listings
else :
number_of_listings=number_of_listings
-Return the number.
- Once the number is returned do the following based on the following criteria:
- If the number is equal to or less than 14 then:
- Submit the php form. See the details below.
- If the number is over 14 then:
- Replace the processing... message with the following message and insert TWO buttons, one that says "SUBMIT" and the other that says "EDIT". Note that {0} should be the returned number divided by 7. Ex 21/7 = 3
- "Based on your search criteria, we estimate that you will receive approximately {0} alerts a day. If this is ok, just press SUBMIT. If not, please press EDIT and be more specific in your search criteria."
- If the user presses submit then:
- Submit the php form. See the details below.
- If the user presses edit then:
- Remove the expanded window and buttons and keep the user on the home page and start the process all over again when they hit "Go".
**************************************************************************************************************
The website currently uses a web form to collect data input into variable fields and submits that data to a php file that translates the submitted data into a .txt file.
The following variables have input variables:
email, phone, item, pricemin, pricemax, zip, miles, vmake, vmodel, minmileage, maxmileage, year, carseller, doors, propertytype, city, state, homesller, minacres, maxacres, minsqfeet, maxsqfeet, minbedrooms, maxbedrooms, carsearch, homesearch
The web form opens with this script:
<form id="Contact" method="post" action="[login to view URL]">
And the submit button looks like this:
<input type="submit" value="Go"></input>
The php file “[login to view URL]” currently has this script:
<?php
header("Location:[login to view URL]");
$email=$_POST['email'];
$phone=$_POST['phone'];
$item=$_POST['item'];
$pricemin=$_POST['pricemin'];
$pricemax=$_POST['pricemax'];
$zip=$_POST['zip'];
$miles=$_POST['miles'];
$carsearch=$_POST['carsearch'];
$vmake=$_POST['vmake'];
$vmodel=$_POST['vmodel'];
$minmileage=$_POST['minmileage'];
$maxmileage=$_POST['maxmileage'];
$year=$_POST['year'];
$carseller=$_POST['carseller'];
$doors=$_POST['doors'];
$homesearch=$_POST['homesearch'];
$propertytype=$_POST['propertytype'];
$city=$_POST['city'];
$state=$_POST['state'];
$homeseller=$_POST['homeseller'];
$minacres=$_POST['minacres'];
$maxacres=$_POST['maxacres'];
$minsqfeet=$_POST['minsqfeet'];
$maxsqfeet=$_POST['maxsqfeet'];
$minbedrooms=$_POST['minbedrooms'];
$maxbedrooms=$_POST['maxbedrooms'];
$url="[login to view URL]";
$id=file($url);
$next=$id[0]+1;
$fp=fopen("form$[login to view URL]", "a");
$fh=fopen($url, 'w') or die ("cant open file");
$savestring = $carsearch . "\n" . $homesearch . "\n" . $next . "\n" . $email . "\n" . $phone . "\n" . $item . "\n" . $pricemin . "\n" . $pricemax . "\n" . $zip . "\n" . $miles . "\n" . $vmake . "\n" . $vmodel . "\n" . $minmileage . "\n" . $maxmileage . "\n" . implode(",",$_POST['year']) . "\n" . implode(",",$_POST['carseller']) . "\n" . implode(",",$_POST['doors']) . "\n" . $propertytype . "\n" . $city . "\n" . $state . "\n" . $homeseller . "\n" . $minacres . "\n" . $maxacres . "\n" . $minsqfeet . "\n" . $maxsqfeet . "\n" . $minbedrooms . "\n" . $maxbedrooms . "\n";
fwrite($fp, $savestring);
fclose($fp);
unlink("[login to view URL]");
$fa=fopen("[login to view URL]", "a");
fwrite($fa, $next);
fclose($fa)
?>