Forum Moderators: coopster
How can I fix this so that they are taken back to their serahc results when clicking the back button?
Code for search results page:
[code]
<?
include_once "../main.php";
include_once "../configuration.inc.php";
$day = date(d);
$month = date(m);
$year = date(Y);
$del = "delete from job_post where EXday = \"$day\" and EXmonth = \"$month\" and EXyear = \"$year\" ";
$rdel = mysql_query($del) or die(mysql_error());
$sch = array();
if (!empty($position))
{
$sch[] = "position like '%$_POST[position]%'";
}
if (!empty($country))
{
$sch[] = "CompanyCountry = \"$_POST[country]\" ";
}
if (!empty($JobIn))
{
$sch[] = "JobIn like '%$_POST[JobIn]%' ";
}
if (!empty($JobCategory))
{
$sch[] = "JobCategory like '%$_POST[JobCategory]%' ";
}
if (!empty($careerlevel))
{
$sch[] = "j_target = '$_POST[careerlevel]'";
}
if (!empty($employment_type))
{
$sch[] = "employment_type = '$_POST[employment_type]'";
}
if (!empty($kw))
{
$sch[] = "description like '%$_POST[kw]%'";
}
if (!$ByPage) $ByPage=25;
if (!$Start) $Start=0;
if($sm == 'or')
{
$qs = "select * from job_post ".(($sch)?"where ".join(" or ", $sch):"")." limit $Start,$ByPage";
$qss = "select * from job_post ".(($sch)?"where ".join(" or ", $sch):"");
}
elseif($sm == 'and')
{
$qs = "select * from job_post ".(($sch)?"where ".join(" and ", $sch):"")." limit $Start,$ByPage";
$qss = "select * from job_post ".(($sch)?"where ".join(" and ", $sch):"");
}
$rqs = mysql_query($qs) or die(mysql_error());
$rqss = mysql_query($qss) or die(mysql_error());
$rr = mysql_num_rows($rqss);
if($rr == '0')
{
echo "<br><br><font size='2' face='Verdana' color='black'>Sorry, no results found.</font> : <a href='http://www.example.com/jobseekers/job-search.php'><font font size='2' face='Verdana' color='#000099'>search again</font></a></center><br>";
}
elseif($rr == '1')
{
echo "<br><br><center><b> $SRONE. </b></center>";
}
elseif($rr > '1')
{
echo "<br><b><font size='1' face='Verdana' color='black'>Your search returned <font font size='2' face='Verdana' color='#000099'>$rr</font> results. </b></font></center>";
}
$col = "cococo";
echo "<br><table width=100% align=center cellpadding='3' cellspacing=1>
<tr bgcolor=$s2>
<td><font size='2' face='Verdana' color='white'><b>Position:</b></font> </td>
<td><b><font size='2' face='Verdana' color='white'>$JOBCATEGORY</b></font> </td>
<td width=85><center><b><font size='2' face='Verdana' color='white'>Expires in:</b></font></center></td>
</tr>";
while($as = mysql_fetch_array($rqs))
{
//$ex13 = date('d', mktime(0,0,0, $as[EXmonth] - date(m), $as[EXday] - date(d), $as[EXyear] - date(Y)));
$day = date(d);
$month = date(m);
$year = date(Y);
$EXdate = "$as[EXyear]"."-"."$as[EXmonth]"."-"."$as[EXday]";
$dnes = "$year"."-"."$month"."-"."$day";
$qd = "select to_days('$EXdate') - to_days('$dnes')";
$rqd = mysql_query($qd) or die(mysql_error());
$ex13 = mysql_fetch_array($rqd);
if($col == "cococo")
{
$col = "dddddd";
}
else
{
$col = "cococo";
}
echo "<tr style=\"font-size:12\">
<td><a class=TN href=\"job-info.php?job_id=$as[job_id]\"><b><font size='1' face='Verdana' color='#000099'> $as[position]</a></b></font></td>
<td><font size='1' face='Verdana' color='black'> $as[JobCategory] </font></td>
<td align=center><font size='1' face='Verdana' color='black'> $ex13[0] days</font></td>
</tr>";
}
if($sm == 'or')
{
$qs2 = "select * from job_post ".(($sch)?"where ".join(" or ", $sch):"");
}
elseif($sm == 'and')
{
$qs2 = "select * from job_post ".(($sch)?"where ".join(" and ", $sch):"");
}
$rqs2 = mysql_query($qs2) or die(mysql_error());
$rr2 = mysql_num_rows($rqs2);
echo "</table>";
echo "<table width=95% align=center><tr>";
if ($rr2 <= $ByPage && $Start == '0')
{
}
if ( $Start > 0 )
{
$nom1 = $Start - $ByPage;
echo "<td align=left><br><a href=\"job-search2.php?sm=$sm&position=$position& CompanyCountry=$CompanyCountry&JobIn=$JobIn& JobCategory=$JobCategory&careerlevel=$careerlevel& target_company=$target_company&relocate=$relocate& country=$country&city=$city&kw=$kw&Start=$nom1\"><font font size='2' face='Verdana' color='#000099'>< previous page</font></a><br></td>";
}
if ($rr2 > $Start + $ByPage ¦¦ ($Start == 0 && $rr2 > $ByPage))
{
$nom = $Start + $ByPage;
echo "<td align=right><br><a href=\"job-search2.php?sm=$sm&position=$position& CompanyCountry=$CompanyCountry&JobIn=$JobIn& JobCategory=$JobCategory&careerlevel=$careerlevel& target_company=$target_company&relocate=$relocate& country=$country&city=$city&kw=$kw&Start=$nom\"><font font size='2' face='Verdana' color='#000099'>next page ></font></a><br><br></td>";
}
echo "</tr></table>";
?>
<? include_once('../footer.php');?>
[code]
[edited by: jatar_k at 4:04 pm (utc) on Aug. 19, 2005]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]
I used the get method in my search form and changed all occurances of 'post' to $_GET, the search is working but its still not passing the values back to my search page when clicking the back button?
Dont i need to fetch them from the header or something on my search page?
This is what my search page looks like :
<?
include_once "../main-jobsearch.php";
include_once "../configuration.inc.php";
?><br><font color="navy" face="verdana" size="2"><b>Search for a job:</b></font><br><br><br>
<form action=job-search2.php method=get>
<table align = center>
<tr>
<td><font size='2' face='Verdana' color='black'>Keyword search: </font></td>
<td><input type=text name=kw></td>
**** Plus all the rest of the code
step1 - form: [domain.com...]
step2 - submit form[GET]: [domain.com...]
step3 - click on result: [otherdomain.com...]
step4 - click [back] on a browser: [domain.com...] again (i think this evens has to be cached)
Using the POST method form input field names and data are passed via headers:
step1 - form: [domain.com...]
step2 - submit form[POST]: [domain.com...]
step3 - click on result: [otherdomain.com...]
step4 - click [back] on a browser: [domain.com...] (no data/data is expired)
I tested this with a simple example and it worked:
form.php:
<form method="get" action="search.php">
<input type="text" name="name">
<input type="submit" name="submit" value="Submit">
</form>
search.php:
<?
if($_GET['name'])echo '<a href="http://www.php.net">link</a>';
?>
So first thing you should check is that you are using GET method and form data is passed via URI. (there might be some server/client configuration that forces all form submits use POST method, also some javascript might add problems too)
If that doesnt help, try using this in form file/script:
<?php
header("Cache-control: private");
?>
more info on methods: [w3.org...]
Hope something helps..