Hi all,
I’m running php 4.3.2 on apache with mysql. I’ve looked through past threads, the internet and had no luck with my problem. Basically, I’m developing a web-style interface for a database system. I have a couple of pages that are forms for searches. SO say for instance, one is called search.php, when it is submitted, the action is results.php. results.php calls a function called browse that produces the first page of results. The browse function then calls the results.php function to display the second page for previous/next browsing and so on for subsequent pages. There are links in the results page to other parts of the site. The problem I’m having is that when the user has gone to a link from the results page and then press the ‘back’ button to get back to the search results, I get the following error in IE:
Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.
I also get a similar problem when I try the script on netscape, something about data for the post operation missing. Does anyone have anyone idea how I can overcome this. I think it’s got something to do with the calling of the results.php script from browse function over and over again.
Results.php:
<?php
session_start();
if (@$HTTP_SESSION_VARS["login"] != "yes")
{
header("Location:login.php");
exit();
}
?>
<html>
<head><title>Search Results</title>
</head>
<body>
<form method = 'POST' action='basicSearchResults.php?first=nope&offset=$rowsOffset'>
<h1>Basic Search Results</h1>
<?php
include ("browse.php");
$scriptName = "basicSearchResults.php";
$searchForm = "basicSearch.html";
$link_id= mydb_connect();
function searchAllDatabase ($search_query){
global $field_aliases_array;
// $lastElement = "rc.rec_id";
$lastElement = "a.description";
$searchAll = ""; //as the query is appended below
global $numericalFields;
foreach ($field_aliases_array as $table)
{
foreach ($table as $field_alias=>$field)
{
if ($field!="f.audio")
{
$op = " LIKE ";
foreach($numericalFields as $numeric)
{
if ($field == $numeric)
$op = "=";
}
$searchAll.= $field.$op.$search_query;
if ($field != $lastElement)
$searchAll.= " OR ";
}
}//end foreach
}
return $searchAll;
}//end function
if ($_REQUEST["first"] == "yes"){ //it’s the first time the form has been submitted
//construct the search query
$search_query = $HTTP_POST_VARS["search_query"];
$rows_per_page = $HTTP_POST_VARS["rows_per_page"];
$offset = 0;
//if the first page of results has already been shown i.e. script has already been run once on this query
}else{
$query =$_POST["query"];
$rows_per_page =$_POST["rows_per_page"];
$offset =$_POST["offset"];
if ($_POST["submit"] == "Previous")
$offset = $_POST["offset"] - $rows_per_page;
else
$offset =$_POST["offset"] + $rows_per_page;
}//end if first
echo($query);
//initialise the browse function parameters
//query prefix for the next/previous links
$browseString = "first=nope";
//page hearder for browse screen
$pageHeader = "fill in page header!";
//HTML table column headers
$header[0]["header"] = "Composition Title";
$header[1]["header"] = "Mov ID";
$header[2]["header"] = "Movement No";
$header[3]["header"] = "Frag ID";
$header[4]["header"] = "Composer";
$header[5]["header"] = "Year";
$header[6]["header"] = "Tempo";
$header[7]["header"] = "Tonality";
$header[8]["header"] = "Length";
//query attributes to display in table columns
$header[0]["attrib"] = "0";
$header[1]["attrib"] = "1";
$header[2]["attrib"] = "2";
$header[3]["attrib"] = "3";
$header[4]["attrib"] = "4";
$header[5]["attrib"] = "5";
$header[6]["attrib"] = "6";
$header[7]["attrib"] = "7";
$header[8]["attrib"] = "8";
$searchType = "advanced";
browse($searchForm,$scriptName, $link_id, $browseString, $offset, $query, $pageHeader, $header, $rows_per_page, $searchType,$HTTP_SESSION_VARS["userLevel"]);
?>
</body>
</html>
structure of browse.php:
<?php
function browse($searchForm,
$scriptName,
$connection,
$browseString,
$rowsOffset,
$query,
$pageHeader,
$header,
$rows_per_page,
$searchType,
$userLevel)
{
echo "<input type = 'hidden' name = 'query' value = '$query'>";
echo "<input type = 'hidden' name = 'rows_per_page' value = $rows_per_page>";
define("ROWS",$rows_per_page);
if (!$result = mysql_query ($query, $connection))
showerror();
$rowsFound = mysql_num_rows($result);
if ($rowsFound != 0)
{
$previousOffset = $rowsOffset - $rows_per_page;
$nextOffset = $rowsOffset + $rows_per_page;
if (!mysql_data_seek($result, $rowsOffset))
showerror();
echo "<table cellpadding = 3 border =0>\n\t<tr>";
foreach ($header as $element)
echo "\n\t<th>". $element["header"]. "</th>";
echo "\n</tr>";
for ($rowCounter = 0;
(($rowCounter < $rows_per_page ) && ($row = @mysql_fetch_array($result)));
$rowCounter++)
{
echo"\n<tr>";
foreach($header as $element)
{
echo "\n\t<td>";
$temp = $element["attrib"];
echo $row["$temp"];
echo "</td>";
}
//any additional information to include in each row e.g. links
if ($searchType == "advanced" || $searchType == "basic")
echo "<td><a href = \"play.php?fragID=".$fragID."\"><IMG SRC=\"audio.GIF\" height =35 width = 35></a></td>";
echo "\n</tr>\n";
}
echo "\n</table>\n";
echo "<p>".($rowsOffset + 1). "-".($rowCounter + $rowsOffset)." of ";
echo "$rowsFound records matching your criteria<br> ";
if($rowsOffset > 0){
echo "<input type = 'hidden' name = 'offset' value = $rowsOffset>";
echo "\n\t<a href=\"" .$scriptName. "?offset=".rawurlencode($previousOffset)."&".$browseString . "\">";
echo "<br><input type = 'submit' name = 'submit' value = 'Previous'></a>";
}else{
echo "Previous ";}
&n bsp;
if (($row!= false) && ($rowsFound > $nextOffset)){
echo "<input type = 'hidden' name = 'offset' value = $rowsOffset>";
echo "\n\t<a href=\"" .$scriptName. "?offset=".rawurlencode($nextOffset)."&".$browseString ."\">";
echo "\n<input type = 'submit' name = 'submit' value = 'Next'></a>";
}else{
echo "Next ";
}
}//end if rowsFounds = 0
else
{
echo "<p>No rows found matching your criteria.</p>";
}
if($searchType == "advanced" || $searchType == "basic")
echo "<p><a href=\"".$searchForm. "\">Back to Search</a></p>";
}
?>
I’m sorry it’s so long.Any ideas??
Manni
I’m running php 4.3.2 on apache with mysql. I’ve looked through past threads, the internet and had no luck with my problem. Basically, I’m developing a web-style interface for a database system. I have a couple of pages that are forms for searches. SO say for instance, one is called search.php, when it is submitted, the action is results.php. results.php calls a function called browse that produces the first page of results. The browse function then calls the results.php function to display the second page for previous/next browsing and so on for subsequent pages. There are links in the results page to other parts of the site. The problem I’m having is that when the user has gone to a link from the results page and then press the ‘back’ button to get back to the search results, I get the following error in IE:
Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.
I also get a similar problem when I try the script on netscape, something about data for the post operation missing. Does anyone have anyone idea how I can overcome this. I think it’s got something to do with the calling of the results.php script from browse function over and over again.
Results.php:
<?php
session_start();
if (@$HTTP_SESSION_VARS["login"] != "yes")
{
header("Location:login.php");
exit();
}
?>
<html>
<head><title>Search Results</title>
</head>
<body>
<form method = 'POST' action='basicSearchResults.php?first=nope&offset=$rowsOffset'>
<h1>Basic Search Results</h1>
<?php
include ("browse.php");
$scriptName = "basicSearchResults.php";
$searchForm = "basicSearch.html";
$link_id= mydb_connect();
function searchAllDatabase ($search_query){
global $field_aliases_array;
// $lastElement = "rc.rec_id";
$lastElement = "a.description";
$searchAll = ""; //as the query is appended below
global $numericalFields;
foreach ($field_aliases_array as $table)
{
foreach ($table as $field_alias=>$field)
{
if ($field!="f.audio")
{
$op = " LIKE ";
foreach($numericalFields as $numeric)
{
if ($field == $numeric)
$op = "=";
}
$searchAll.= $field.$op.$search_query;
if ($field != $lastElement)
$searchAll.= " OR ";
}
}//end foreach
}
return $searchAll;
}//end function
if ($_REQUEST["first"] == "yes"){ //it’s the first time the form has been submitted
//construct the search query
$search_query = $HTTP_POST_VARS["search_query"];
$rows_per_page = $HTTP_POST_VARS["rows_per_page"];
$offset = 0;
//if the first page of results has already been shown i.e. script has already been run once on this query
}else{
$query =$_POST["query"];
$rows_per_page =$_POST["rows_per_page"];
$offset =$_POST["offset"];
if ($_POST["submit"] == "Previous")
$offset = $_POST["offset"] - $rows_per_page;
else
$offset =$_POST["offset"] + $rows_per_page;
}//end if first
echo($query);
//initialise the browse function parameters
//query prefix for the next/previous links
$browseString = "first=nope";
//page hearder for browse screen
$pageHeader = "fill in page header!";
//HTML table column headers
$header[0]["header"] = "Composition Title";
$header[1]["header"] = "Mov ID";
$header[2]["header"] = "Movement No";
$header[3]["header"] = "Frag ID";
$header[4]["header"] = "Composer";
$header[5]["header"] = "Year";
$header[6]["header"] = "Tempo";
$header[7]["header"] = "Tonality";
$header[8]["header"] = "Length";
//query attributes to display in table columns
$header[0]["attrib"] = "0";
$header[1]["attrib"] = "1";
$header[2]["attrib"] = "2";
$header[3]["attrib"] = "3";
$header[4]["attrib"] = "4";
$header[5]["attrib"] = "5";
$header[6]["attrib"] = "6";
$header[7]["attrib"] = "7";
$header[8]["attrib"] = "8";
$searchType = "advanced";
browse($searchForm,$scriptName, $link_id, $browseString, $offset, $query, $pageHeader, $header, $rows_per_page, $searchType,$HTTP_SESSION_VARS["userLevel"]);
?>
</body>
</html>
structure of browse.php:
<?php
function browse($searchForm,
$scriptName,
$connection,
$browseString,
$rowsOffset,
$query,
$pageHeader,
$header,
$rows_per_page,
$searchType,
$userLevel)
{
echo "<input type = 'hidden' name = 'query' value = '$query'>";
echo "<input type = 'hidden' name = 'rows_per_page' value = $rows_per_page>";
define("ROWS",$rows_per_page);
if (!$result = mysql_query ($query, $connection))
showerror();
$rowsFound = mysql_num_rows($result);
if ($rowsFound != 0)
{
$previousOffset = $rowsOffset - $rows_per_page;
$nextOffset = $rowsOffset + $rows_per_page;
if (!mysql_data_seek($result, $rowsOffset))
showerror();
echo "<table cellpadding = 3 border =0>\n\t<tr>";
foreach ($header as $element)
echo "\n\t<th>". $element["header"]. "</th>";
echo "\n</tr>";
for ($rowCounter = 0;
(($rowCounter < $rows_per_page ) && ($row = @mysql_fetch_array($result)));
$rowCounter++)
{
echo"\n<tr>";
foreach($header as $element)
{
echo "\n\t<td>";
$temp = $element["attrib"];
echo $row["$temp"];
echo "</td>";
}
//any additional information to include in each row e.g. links
if ($searchType == "advanced" || $searchType == "basic")
echo "<td><a href = \"play.php?fragID=".$fragID."\"><IMG SRC=\"audio.GIF\" height =35 width = 35></a></td>";
echo "\n</tr>\n";
}
echo "\n</table>\n";
echo "<p>".($rowsOffset + 1). "-".($rowCounter + $rowsOffset)." of ";
echo "$rowsFound records matching your criteria<br> ";
if($rowsOffset > 0){
echo "<input type = 'hidden' name = 'offset' value = $rowsOffset>";
echo "\n\t<a href=\"" .$scriptName. "?offset=".rawurlencode($previousOffset)."&".$browseString . "\">";
echo "<br><input type = 'submit' name = 'submit' value = 'Previous'></a>";
}else{
echo "Previous ";}
&n bsp;
if (($row!= false) && ($rowsFound > $nextOffset)){
echo "<input type = 'hidden' name = 'offset' value = $rowsOffset>";
echo "\n\t<a href=\"" .$scriptName. "?offset=".rawurlencode($nextOffset)."&".$browseString ."\">";
echo "\n<input type = 'submit' name = 'submit' value = 'Next'></a>";
}else{
echo "Next ";
}
}//end if rowsFounds = 0
else
{
echo "<p>No rows found matching your criteria.</p>";
}
if($searchType == "advanced" || $searchType == "basic")
echo "<p><a href=\"".$searchForm. "\">Back to Search</a></p>";
}
?>
I’m sorry it’s so long.Any ideas??
Manni