By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

"page Not Found" after submitting form to $_SERVER['PHP_SELF'] through Post Action

P: n/a
If I submit my for using a get action the resulting page loads . If I
use a post action I get an error page saying "The page cannot be
found". I am calling the originating page!!! This happens in IE as
well as FireFox.

This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL
4.1.8 and it works fine.

The problem server is a Win2k server, IIS5, PHP 5.0.4, mySQL 4.1.11.

Any help would be greatly appreciated especially any tips for debugging
the page.

The lovely code for your review:

<?php
// start the session
session_start();
$_SESSION['CallingPage'] = $_SERVER['PHP_SELF'];
$_SESSION['WhichComputer'] = $_SERVER['COMPUTERNAME'];
$_SESSION['WhichServer'] = $_SERVER['SERVER_NAME'];
$_SESSION['TheirIP'] = $_ENV['REMOTE_ADDR'];
$_SESSION['TheirHost'] = $_ENV['REMOTE_HOST'];
header("Cache-control: private"); //IE 6 Fix

$Path2PHP = '../../lib/';

$PageTitle = 'Treasury&nbsp;-- Abandoned Property Search';
$PageHeader = 'Search For Abandoned Property';

if (isset($_POST['submit'])) {
$SectionHeader = 'Abandoned Property Search Results';
}
elseif (isset($_GET['page'])){
$SectionHeader = 'Abandoned Property Search Results';
}
else{
$SectionHeader = 'Search for Abandoned Property';
}
$IncludeMe = 'APHeader.php';
include('APHeader.php');

//Paginator
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
//echo 'Page Count: '.$_GET['page'];
// Define the number of results per page
$max_results = 10;

// Figure out the limit for the query based
// on the current page number.
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
?>
<link href="../css/nh.css" rel="stylesheet" type="text/css">
<?php
if (!isset($_POST['submit']) && (!isset($_GET['page']))) {
?>
<p>&nbsp;</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<table>
<tr><td><font color="#FF0000">*</font> Last Name or Company:
</td><td><input name="ln" size="30" type="text">
Exact<input name="lnExact" type="checkbox"></td></tr>
<tr><td>First Name: </td><td><input name="fn" type="text"></td></tr>
<tr><td><!-- <font color="#FF0000">**</font> -->City:
</td><td><input name="city" type="text"></td></tr>
<tr><td><!-- <font color="#FF0000">**</font> -->Company Holding
Property: </td><td><input name="holder" type="text">
</td></tr>
</table>
<input type="submit" name="submit" value="Search">
<p><font color="#FF0000">*</font> Required Field</p>
<!-- <p><font color="#FF0000">**</font> Not Implemented Yet</p>
--> </form>
<?php for($i = 1; $i <= 7; $i++){
echo '<p>&nbsp;</p>';
}
?>
<?php

} //if (!isset($_POST['submit'])) {
else { //if (!isset($_POST['submit'])) {
if (!isset($_GET['page'])) {
$_SESSION['ln'] = $_POST['ln'];
$_SESSION['fn'] = $_POST['fn'];
$_SESSION['city'] = $_POST['city'];
$_SESSION['refExact'] = $_POST['refExact'];
$_SESSION['lnExact'] = $_POST['lnExact'];

}

$IncludeMe = 'db.php';
include($IncludeMe);
?>
<!-- Refine Search Table -->
<br />
<p><span class="SubSectionLabel">Refine Search</span></p>
<div name="RefineSearch">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="100%" bgcolor="#399608" cellpadding="1" cellspacing="0">
<tr ><th width="30%" style="color:cornsilk; font-size:12px">Last
Name</th>
<th width="25%" style="color:cornsilk; font-size:12px">First Name</th>
<th width="25%" style="color:cornsilk; font-size:12px">City</th>
<th width="20%" style="color:cornsilk; font-size:12px;">Exact
<input name="refExact" type="checkbox"></th></tr>
<tr>
<td><input type="text" name="ln" size="20" value="<?php echo
$_SESSION['ln'] ?>"></td>
<td><input type="text" name="fn" size="15" value="<?php echo
$_SESSION['fn'] ?>"></td>
<td><input type="text" name="city" size="15" value="<?php echo
$_SESSION['city'] ?>"></td>
<td><input type="submit" name="submit" value="Refine Search"></td>
</tr>
</table>
</form>
</div>
<?php
//Send a query to the server
if (!isset($_SESSION['lnExact'])) {
if (!isset($_SESSION['lnExact'])) {
$_SESSION['strWhere']=" where lname like '%".$_SESSION['ln']."%' ";
}
else {
$_SESSION['strWhere'] =" where lname = '".$_SESSION['ln']."' ";
}
} //if (!isset($_POST['lnExact'])) {
else {
$_SESSION['strWhere'] =" where lname = '".$_SESSION['ln']."' ";
} //else {
if (empty($_SESSION['fn'])) {
$_SESSION['strFN']="";
} //if (!isset($_POST['fn'])) {
else {
if (!isset($_SESSION['refExact'])) {
$_SESSION['strFN']=" AND fname like '".$_SESSION['fn']."%' ";
}
else {
$_SESSION['strFN']=" AND fname = '".$_SESSION['fn']."' ";
}
//$strFN=" AND fname like '%$fn%' ";
} //else {

if (empty($_SESSION['city'])) {
$_SESSION['strCity']="";
} //if (!isset($_POST['fn'])) {
else {
if (!isset($_SESSION['refExact'])) {
$_SESSION['strCity']=" AND OWNERS.city like '".$_SESSION['city']."%'
";
}
else {
$_SESSION['strCity']=" AND OWNERS.city = '".$_SESSION['city']."' ";
}
//$strCity=" AND OWNERS.city like '%$city%' ";
} //else {
If ($page == 1){
$qcount = 'Select owners.ownerid from
owners'.$_SESSION['strWhere'].$_SESSION['strFN'].$_SESSION['strCity'];
//echo $qcount;
$_SESSION['LastSQL'] = $qcount;
$count=mysqli_query($mysqli,$qcount);
If ($count) {
$_SESSION['counted'] = mysqli_num_rows($count);
//echo 'Counted: '.$counted;
}
}
$SqlStr = "Select owners.PropertyID,owners.lname, owners.fname, ";
$SqlStr = $SqlStr."CONCAT(owners.lname,',',owners.fname) AS nameo, ";
$SqlStr = $SqlStr."owners.addr1, owners.city, owners.state, ";
$SqlStr = $SqlStr."properties.amount, properties.proptype,
holders.holder ";
$SqlStr = $SqlStr."from owners inner join properties ";
$SqlStr = $SqlStr."on owners.PropertyID = properties.PropertyID ";
$SqlStr = $SqlStr."INNER JOIN holders ";
$SqlStr = $SqlStr."ON properties.holderid = holders.holderid ";
$SqlStr=
$SqlStr.$_SESSION['strWhere'].$_SESSION['strFN'].$_SESSION['strCity'];
$SqlStr= $SqlStr." order by nameo asc limit ".$from.",".$max_results;
$_SESSION['LastSQL'] = $SqlStr;
//Get the resultset
$result=mysqli_query($mysqli, $SqlStr);
if ($result){
//$QueryRowcCount = 1;
//print("Properties : \n<br><br>");
//Fetch the result of the query
echo '<br /><br /><span class="SubSectionLabel">Search
Results</span><br>';

$totalrows = mysqli_num_rows($result);
If ($totalrows > 0){
echo '<table><tr><th>Name</th><th>Last Known Address</th>';
echo '<th>Reported By</th><th>Amount</th></tr>';
}
else {
echo '<p class="Subheader">No Results to Display. Please refine your
search</p>';
}
?>

<?php
while($row=mysqli_fetch_assoc($result)){
if (!isset($QueryRowCount))
{$QueryRowCount = 0;
}
if (!isset($BackColor))
{$BackColor = 'white';
}
$QueryRowCount++;
$Modulus = $totalrows % $QueryRowCount;

if($BackColor !="white") { //if($BackColor !="white")
$BackColor="white";
} //if($BackColor !="white")
else {
$BackColor="cornsilk";
} //if($BackColor !="white")

echo '<tr bgcolor="'.$BackColor.'"';
echo " onMouseOver='";
echo 'this.style.background="cadetblue"'."'";
echo " onMouseOut='";
echo 'this.style.background="'.$BackColor.'"'."'>";
echo '<td class="APtext">';
//echo '<a href="ShowProp.php?PID='. $row['PropertyID'].'"';
//echo ' onMouseOver="window.status='."'Click the link to view
information about this property'".';return true;" ';
//echo 'onMouseOut="window.status='."'New Hampshire State
Treasury'".';return true;">';
//echo '<acronym title="Click the Detail Button to view Property
Information" class="noline">';

echo '<div style="font-size:12px; cursor:pointer; color:#333300"
onClick="window.location=';

echo "'ShowProp.php?PID=";
echo $row['PropertyID'];
echo "'";
echo '">';
$displayname = $row['lname'];
if (!empty($row['fname'])) {
$displayname .= ", ".$row['fname'];
}
//$displayname = substr($displayname,0,20);
//echo $displayname. "<br /> ";
echo '<acronym title="Click here to view Property Information"
class="noline">';
echo $displayname;
echo '&nbsp;<img src="../../images/Mag1.jpg" alt="See More
Information about this Property">';
echo '</acronym>';
//echo '<button
onClick="window.location='."'ShowProp.php?PID=".$r ow['PropertyID']."'".'">Details</button></acronym>';
echo '</div>';
//echo "</a>";
echo "</td>";
$OAddr = "";
/* $checkvar = $row['addr1'];
if (empty($checkvar)) {}
//$OAddr = "";
//}
else { //if (empty($checkvar))
$OAddr = trim($row['addr1'])."<br>";
} //if (empty($checkvar)) */
$OAddr = 'Not Disclosed<br />';
$checkvar = $row['city'];
if (empty($checkvar)) {}
else { //else
$OAddr = $OAddr.trim($row['city']);
$checkvar = $row['state'];
if (empty($checkvar)) {}
else {
$OAddr = $OAddr.', ';
} //else {
} //else
$checkvar = $row['state'];
if (empty($checkvar)) {}
else {
$OAddr = $OAddr.trim($checkvar);
} //else {
if (empty($OAddr)) {
$OAddr = "Not Disclosed";
} //if (empty($OAddr))
echo '<td class="APtext">'.$OAddr.'</td><td class="APtext">';
//$holder = substr($row['holder'],0,20);
$holder = $row['holder'];
echo $holder.'</td><td class="APtext">';
$propertytype = $row['proptype'];
if ($propertytype == 'SC')
{//A stock Property Type
echo 'Stock Transaction';
}
else{
$checkvar = $row['amount'];
switch ($checkvar) {
case ($checkvar <100):
echo "Under $100";
break;
case ($checkvar >100):
echo "Over $100";
break;
default:
echo "Undisclosed";

}
}
echo '</td></tr>';
}
//echo "<td>".$row['city']. "</td></tr>";
} //while($row=mysqli_fetch_assoc($result)){
echo "</table>";
// Figure out the total number of pages. Always round up using ceil()
// Build Page Number Hyperlinks
echo '<table width="100%"><tr><th align="center" width="100%">Select a
Page</th></tr><tr><td align="center">';
$total_pages = ceil($_SESSION['counted'] / $max_results);
//echo "<center><br />";
// Build Previous Link

if($page > 1){
$prev = ($page - 1);
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$prev\">Previous</a>&nbsp;";
}

for($i = $page; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i&nbsp;";
} else {
echo "<a
href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>&nbsp;";
}
if ($i > ($page + 5)) {
break;
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</td></tr></table>";
//The mysqli_fetch_assoc() function is used to return an associative
array representing the next row in the result set for the result
represented by the result parameter, where each key in the array
represents the name of one of the result set's columns.
if ($totalrows > 5) {
?>
<!-- Refine Search Table -->
<br />
<p><span class="SubSectionLabel">Refine Search</span></p>
<div name="RefineSearch">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="100%" bgcolor="#399608" cellpadding="1" cellspacing="0">
<tr ><th width="30%" style="color:cornsilk; font-size:12px">Last
Name</th>
<th width="25%" style="color:cornsilk; font-size:12px">First Name</th>
<th width="25%" style="color:cornsilk; font-size:12px">City</th>
<th width="20%" style="color:cornsilk; font-size:12px;">Exact
<input name="refExact" type="checkbox"></th></tr>
<tr>
<td><input type="text" name="ln" size="20" value="<?php echo $ln
?>"></td>
<td><input type="text" name="fn" size="15" value="<?php echo $fn
?>"></td>
<td><input type="text" name="city" size="15" value="<?php echo $city
?>"></td>
<td><input type="submit" name="submit" value="Refine Search"></td>
</tr>
</table>
</form>
</div>
<?php
}

$totalrows = 10;

//Destroy the resultset and free the memory
mysqli_free_result($result);
} //if ($result){
for($i = 10; $i <= 10; $i++){
echo '<p>&nbsp;</p>';
}
//Close the connection
if (isset($mysqli)) {
mysqli_close($mysqli);
} //if (!isset($mysqli)) {

/* echo
'<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>';
*/
/* break;
} */
//} //if (!isset($_POST['submit'])) {
include('APFooter.htm');
?>

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Holla!

I did not have the time to examine all the code but most of the servers
I've published to are givint Page not Found or error 500 directly if
some variables are missing or something is gone wrong with the script.

A proposition is to examine more carefully the code or database 'cause
as I said I didn't manage to check the code.

Hope I helped! (daughtly ) :)

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.