I am using GET to switch the main part of my site to load pages and keep the top section and right section of the site the same. I am using an include script to do this
<?php
if (isset($_GET['page'])){
$page = $_GET['page'];
$pageset = $page.".php";
include $pageset;
}else{
include 'home.php';
}
?>
and on the menu I have links like this index.php?page=search
Now my problem is loading my search page which is the main part of my site and that 1 page uses itself to do form processing and querying and all that. When I try hitting the submit button all it does it go back to index.php You can see an example here http://boringdays.com/rabble/ and click search at top
here is the code for search.php
<p id="header">Search</p>
<p id="hsub">
Use search below</p><br><br>
<?php
include 'connect.php';
$result = pg_query("SELECT * FROM building");
$select_option = "<select name=\"bname\">";
while ($row = pg_fetch_array($result)){
$select_option .= "<option value=\"".$row['id']."\">".$row['name']."</option>\n";
}
$self = $_SERVER["PHP_SELF"];
$select_option .= "</select>";
echo "<FORM action=$self method=POST>";
echo "Select the building your classroom is in from the drop down menu $select_option";
echo "<input type=submit name=submit></FORM>";
if ($_POST['submit']){
$bid = $_POST['bname'];
$query = "SELECT *, room.id AS rid FROM room INNER JOIN building ON room.bid = building.id WHERE bid = $bid ";
$result = pg_query($query);
$rows = pg_num_rows($result);
if ($rows < 1){
echo "No records found<br>";
}else{
$build = $row['name'];
echo "<b>Results</b><br><hr>";
while ($row = pg_fetch_assoc($result)) {
$room = $row['room_num'];
$rid = $row['rid'];
$build = $row['name'];
$comps = $row['numcomps'];
echo "<a href=".$self. "?rid=$rid&room=$room&building=$build&comps=$comps>"."$room</a> ";
}
}
}
if (isset($_GET['rid'])){
$rid = $_GET['rid'];
$building = $_GET['building'];
$room = $_GET['room'];
$comps = $_GET['comps'];
include 'connect.php';
$query = "SELECT * FROM softroom
INNER JOIN room ON softroom.rid = room.id
INNER JOIN software on softroom.sid = software.id
WHERE rid = $rid";
$result = pg_query($query);
$rows = pg_num_rows($result);
if ($rows < 1){
echo "No records found";
}else{
echo "<b>Results</b>";
echo "<table class=hart><tr><td class=fill2>#</td><td class=fill2>Software</td><td class=fill2>Version</td><td
class=fill2>Website</td><td class=fill2>Added</td></tr>";
$count = 0;
while ($row = pg_fetch_assoc($result)){
$mtype = $row['mtype'];
$ctype = $row['ctype'];
$map = "images/building/$building/maps/$room.jpg";
$monitors = "images/building/$building/monitors/$room.jpg";
$computers = "images/building/$building/computers/$room.jpg";
if (file_exists($map)){
$map = "<img src=images/building/$building/maps/$room.jpg>";
}else{
$map = "<img src=images/maps.jpg>";
}
if (file_exists($monitors)){
$monitors = "<img src=images/building/$building/monitors/$room.jpg>";
}else{
$monitors = "<img src=images/monitors.jpg>";
}
if (file_exists($computers)){
$computers = "<img src=images/building/$building/computers/$room.jpg>";
}else{
$computers = "<img src=images/computers.jpg>";
}
$software = $row['title'];
$version = $row['version'];
$site = $row['site'];
$added = date('M d Y', strtotime($row['added']));
$count++;
echo "<tr><td class=chart>$count</td><td class=chart>$software</td><td class=chart>$version</td><td class=chart>
<a href=$site>$site</a></td><td class=chart>$added</td></tr>";
}
echo "</table>";
echo "<br>";
echo "<table class=hart>";
echo "<tr><td class=fill2>Statistics</td><td class=fill2>Monitor</td><td class=fill2>Computer</td><td class=fill2>Map</td></tr>";
echo "<tr><td class=chart>
<b>Room: </b>$building - $room<br><br>
<b>Total PCs: </b> $comps<br><br>
<b>Software: </b>$count<br><br>
<b>Computers: </b>$ctype<br><br>
<b>Monitors: </b>$mtype</td>
<td class=chart align=center>$monitors</td><td class=chart align=center>$computers</td><td class=chart align=center>$map</td></tr>";
echo "</table>";
}
}
?>
I made a copy of search.php to test.php and it works fine on its own. You can try it here http://boringdays.com/rabble/test.php