I am working on a PHP page which can be reached through logging in another index page. This PHP page then starts a session and it displays data from MySQL onto a table.
I am trying to add a filter dropdown box, which can query certain data form table depending on the item selected. This requires the page to get refreshed and come up with certain data from the table.
I initially wanted to start with a simple work, by making the page echo the option that i select from the dropdown box, and the page will initially display "none".
But once I select an option, the PHP page goes white and nothing comes up. But when I goto this page straightaway without logging in, and by commenting out the session commands like "session_start()" and all, the page can display the data based upon the selection in the dropdown box.
So can anyone tell me how to stop this issue, or if you think there is something wrong with the way I found out the cause of the issue, then please notify that as well. Please let me know if you need more details. You can find important parts/details of the code below:
After logging in through index page, the user is shown a page with dropdown box having three items. Based on the selection the appropriate PHP page is displayed. This page that shows the dropdown box for selection has the code in short as follows:
PHP Code:
if ($selected_view == 'A')
include 'A.php';
else if ($selected_view == 'B')
include 'B.php';
else if($selected_view == 'C')
include 'C.php';
I am currently working on the C one, so when I select the C it goes to the PHP page having the following code in short:
PHP Code:
<?php
session_start();
if ( $SESSION['usertype'] == 'Admin')
//the following variables hold the firstname and lastname of the logged in user. This can be used to append with the notes the user adds
{
$user = $SESSION['firstname']." ".$_SESSION['lastname'];
....
?>
My code that I added for adding the dropdown box is as follows: Note-> this code is a simple one and it worked when I created a sample PHP page and ran it:
HTML Code:
<script language="JavaScript" type="text/JavaScript">
function formSubmit()
{
document.getElementById("report_filter").submit();
}
</script>
<form method="post" id="report_filter" action="" >
<select name="try" onchange="formSubmit();">
<option value="all"> All </option>
<option value="Windows"> Windows </option>
<option value="Win 2008"> Win 2008 </option>
<option value="Win 7"> Win 7 </option>
<option value="Win Vista"> Win Vista </option>
<option value ="Linux"> Linux </option>
<option value = "Win 7/Linux"> Win 7/Linux </option>
</select>
</form>
Since I am in the beginning stage, I am just echoing the option that I select in the dropdown box as follows:
PHP Code:
<?php
// I just echo "none" in the beginning, and after a selection is made in te dropdown it should display "ok <the item selected>"
if(!(isset($POST["try"])))
echo "none";
else
echo "ok ".$POST["try"];
?>
But when I make a selection the page goes white and blank.
So I commented out the "session_start();" and other session related commands I saw and ran this page by directly going to it in the browser, instead of navigating through the index page.
In that case, when I make a selection in the dropdown the "ok <item>" is getting displayed.
Please let me know if you need more information/code.
You can also find the code in the below links:
The index.html is in the link:
http://pastebin.com/xkRGVvgR
In index.html the login happens, and then this leads to login_authentication.php whose code is in the link:
http://pastebin.com/xkRGVvgR
This then leads to admin_select.php whose code is in:
http://pastebin.com/xdt0wvP4
After this the nav_admin.php comes and its code is in link:
http://pastebin.com/qY91DxzW
Then finally the code I am working on comes up, and its in the link:
http://pastebin.com/QvDrgLWx
Please let me know if you need any more info.
Thanks