Trying to make simple search with image result in php | html
Posted: Wed Dec 31, 2014 3:58 pm
Okay here is what I'm trying to do...
--------------------------------------------------primary function of what I'm trying to do-----------------------------------------------------------
simply....
if the user picks a zipcode from $loc1 then image $image1(nextday) will show... if user pick a zipcode from $loc2 than $image2(2nd-Day)will hopefully appear under the search box..
i hope that no page "redirect" is necessary... since images are displayed under search box area...
---------------------------------------------------------------------PHP--Form-------------------------------------------------------------------------------
[syntax=php]<?php
$zipcode = $_POST['zipcode'];
$loc1 = array (80013,80015,80126,80127,80128,80129,80130,80134,80135,80138,80160,80161,80162,80163,80165,80166,804 33,80453,80465,80470);
$loc2 = array (80023,80025,80136,80137,80138,80139,80140,80144,80145,80148,80140,80141,80142,80143,80145,80146,804 43,80443,80445,80440);
// need to add whatever validation/sanitation of zip code value here
$image01 = "Next--Day-img.png";
$image02 = "2nd--Day-img.png";
$image03 = "2-3--Day.png";
$image1 = "<img src=img/$image01.png>";
$image2 = "<img src=img/$image02.png>";
$image3 = "<img src=img/$image03.png>";
if(in_array($zipcode, $loc1)) {
echo $image1;
$width = 100;
$height = 662;
}
else if(in_array($zipcode, $loc2)) {
echo $image2;
$width = 100;
$height = 662;
}
else {
echo $image3;
$width = 100;
$height = 662;
$form['#zipcode'] = FALSE;
exit();
}
?>[/syntax]
---------------------------------------------------------------------PHP--Form--End-------------------------------------------------------------------------
---------------------------------------------------------------------HTML--Form-------------------------------------------------------------------------------
[syntax=html]<div class="panel">
<div class="panel-content">
<form id="zipcode" action="<?php echo $_SERVER['PHP_SELF']; ?>" method='POST'>
<input type='text' size="6" maxlength="5" id='searchbar' class='searchbar2'name='zipcode'>
<div id="actions">
<input type='submit' value='Search' onclick="submitclick(); return false;" id='submitbutton' class='zipcode_button'>
<td><id="zipcodeError" value='' class="zipcode_button"/></td>
</div>
</form>
</html>[/syntax]
---------------------------------------------------------------------HTML--Form--End----------------------------------------------------------------------------
--------------------------------------------------primary function of what I'm trying to do-----------------------------------------------------------
simply....
if the user picks a zipcode from $loc1 then image $image1(nextday) will show... if user pick a zipcode from $loc2 than $image2(2nd-Day)will hopefully appear under the search box..
i hope that no page "redirect" is necessary... since images are displayed under search box area...
---------------------------------------------------------------------PHP--Form-------------------------------------------------------------------------------
[syntax=php]<?php
$zipcode = $_POST['zipcode'];
$loc1 = array (80013,80015,80126,80127,80128,80129,80130,80134,80135,80138,80160,80161,80162,80163,80165,80166,804 33,80453,80465,80470);
$loc2 = array (80023,80025,80136,80137,80138,80139,80140,80144,80145,80148,80140,80141,80142,80143,80145,80146,804 43,80443,80445,80440);
// need to add whatever validation/sanitation of zip code value here
$image01 = "Next--Day-img.png";
$image02 = "2nd--Day-img.png";
$image03 = "2-3--Day.png";
$image1 = "<img src=img/$image01.png>";
$image2 = "<img src=img/$image02.png>";
$image3 = "<img src=img/$image03.png>";
if(in_array($zipcode, $loc1)) {
echo $image1;
$width = 100;
$height = 662;
}
else if(in_array($zipcode, $loc2)) {
echo $image2;
$width = 100;
$height = 662;
}
else {
echo $image3;
$width = 100;
$height = 662;
$form['#zipcode'] = FALSE;
exit();
}
?>[/syntax]
---------------------------------------------------------------------PHP--Form--End-------------------------------------------------------------------------
---------------------------------------------------------------------HTML--Form-------------------------------------------------------------------------------
[syntax=html]<div class="panel">
<div class="panel-content">
<form id="zipcode" action="<?php echo $_SERVER['PHP_SELF']; ?>" method='POST'>
<input type='text' size="6" maxlength="5" id='searchbar' class='searchbar2'name='zipcode'>
<div id="actions">
<input type='submit' value='Search' onclick="submitclick(); return false;" id='submitbutton' class='zipcode_button'>
<td><id="zipcodeError" value='' class="zipcode_button"/></td>
</div>
</form>
</html>[/syntax]
---------------------------------------------------------------------HTML--Form--End----------------------------------------------------------------------------