473,505 Members | 13,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
1 4177
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2272
by: Omar E Contreras | last post by:
Hi guys, Let me explain what I want to do in just 3 steps: Step 1: An HTML page that has a form which passes some data to an aspx page Step 2: The aspx page take this values and add some...
7
20897
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
0
2546
by: Joeyej | last post by:
Hi - I'm trying to move/use a web form (containing some javascript field checks) previously hosted on a Windows 2000 server. However, the FORM METHOD="post..." command in the form (shown below)...
3
3049
by: asianboi | last post by:
Hi, In my application, I have a web browser control and load up a local html page. Within the html page, the following code exists. However, when I click on the button that invokes the 'form...
14
2227
by: Robert S | last post by:
I am trying to use POST to transfer data to another page. When I do this, '.' characters get converted to"_". For example: #index.html: <form action="test.php" method="post"> <input...
4
1428
by: G | last post by:
Hello, I have a "two page form" - Page1.aspx and Page2.aspx. I have a function in my Page1.cs file called Button_Click. A simple version: ************************ if (Page.IsValid) {
3
2546
by: paviktherin | last post by:
Okay so I have this form that I have made in order to post comments on a website, the form works fine when I send it to guernica.php for example but it opens it in a new page, I don't know why. Then...
7
14666
by: Anette | last post by:
Hi, I'm very new at PHP. I've tried for a long time now to get a page that has a form in a certain way: 1. When form is submitted the data in a table should be writted on the same page. 2....
3
2430
by: MrCorbeaux | last post by:
My "Email a Webpage" form works find except when the end user receives the email, the URL is text only and not a hyperlink. The "Email a Page" form calls the URL from the previous page using: ...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.