In my page I have some drop down menus, some labels, text boxes and a submit button. After pressing the submit button, it queries the database and shows the data, according to the drop down menu.
In Internet explorer as soon as I press the submit button, all the drop downs, text boxes, labels, buttons disappear, and then they reappear after 4-5 seconds, when the database processing is done.
But in firefox, chrome, and safari browsers, everything is normal. As soon as I press the submit button, it shows the progress bar, and then it shows the retrieved data.
I don't know where the problem lies, and dont know where to start from. Below is my code. Any help is highly appreciated.
Code: Select all
<style>
.progress_wrapper {width:295px;border:1px solid #ccc;position:absolute;top:250px;left:75%;margin-left:-150px}
.progress {height:20px;background-color:#000}
.progress_wrapper2 {width:295px;border:1px solid #757172;position:absolute;top:250px;left:75%;margin-left:-150px}
.progress2 {height:20px;background-color:#757172}
</style>
<script language="Javascript">
function searchAction()
{
document.form1.action = "MainPage.php?action=search";
//alert ("hi");
document.form1.submit();
// alert (document.form1.Month.value);
}
function sendMsg()
{
document.form1.action = "MainPage.php?action=sendMsg";
//alert ("hi");
document.form1.submit();
// alert (document.form1.Month.value);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<?php
$connection = pg_connect("hostaddr=192.0.0.0 port=55 dbname=uni user=post password=cst");
if (!$connection) {
echo("Connection Failed.");
exit;
}
$action = trim($_GET['action']);
?>
<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#757172">
<form id="form1" name="form1" method="post" >
<table width="1171" height="138" border="0">
<tr>
<td width="297"> </td>
<td width="803"><input type="image" name="imageField" id="imageField" src="header.jpg" /></td>
<td width="57"> </td>
</tr>
</table>
<table width="600" border="0">
<tr>
<th width="500" height="194" scope="row"><table width="1154" height="178" border="0">
<tr>
<td width="370" height="61"> </td>
<td width="310"><strong>Month</strong>
<select name="Month" id="Month">
<?php
$months = range (1,12);
$days = range (1, 31);
$years = range (2009, 2015);
$current_year = date("Y");
$current_month = date("m");
$current_day = date("d");
?>
<?php
foreach ($months as $value) {
if($_POST['submitted'] == true){
if($_POST['Month'] == $value){
echo"<option value= '".$_POST['Month']."' selected>".$_POST['Month']."</option>";
}
else{
echo "<OPTION VALUE='".$value."'>".$value." </OPTION>";
}
}else{
if($value == $current_month){
echo "<OPTION VALUE='".$value."' selected>".$current_month." </OPTION>";
}
else{
echo "<OPTION VALUE='".$value."'>".$value." </OPTION>";
}}}
?>
</select>
<strong>Day</strong>
<select name="Day" id="Day">
<?php
foreach ($days as $value) {
if($_POST['submitted'] == true){
if($_POST['Day'] == $value){
echo"<option value= '".$_POST['Day']."' selected>".$_POST['Day']."</option>";
}
else{
echo "<OPTION VALUE='".$value."'>".$value." </OPTION>";
}
}else{
if($value == $current_day){
echo "<OPTION VALUE='".$value."' selected>".$current_day." </OPTION>";
}
else{
echo "<OPTION VALUE='".$value."'>".$value." </OPTION>";
}}}
?>
</select>
<strong>Year</strong><select name="Year" id="Year">
<?php
foreach ($years as $value) {
if($_POST['submitted'] == true){
if($_POST['Year'] == $value){
echo"<option value= '".$_POST['Year']."' selected>".$_POST['Year']."</option>";
}
else{
echo "<OPTION VALUE='".$value."'>".$value." </OPTION>";
}
}else{
if($value == $current_year){
echo "<OPTION VALUE='".$value."' selected>".$current_year." </OPTION>";
}
else{
echo "<OPTION VALUE='".$value."'>".$value." </OPTION>";
}}}
?>
</select></td>
<td width="460"> </td>
</tr>
<tr>
<td height="106"> </td>
<?php
$time = array(array("12:00 AM","1:00 AM","2:00 AM", "3:00 AM", "4:00 AM","5:00 AM", "6:00 AM","7:00 AM", "8:00 AM", "9:00 AM", "10:00 AM", "11:00 AM","12:00 PM","1:00 PM","2:00 PM", "3:00 PM", "4:00 PM","5:00 PM", "6:00 PM","7:00 PM", "8:00 PM", "9:00 PM", "10:00 PM", "11:00 PM"),
array("0","60","120","180","240","300","360","420","480","540","600","660","720","780","840","900","960","1020","1080","1140","1200","1260","1320","1380"));
?>
<td><p><strong>Start Time
</strong></p>
<p><strong>End Time</strong></p>
<p><strong>Location
</strong></p>
<p><strong>Filter by Hours
</strong></p></td>
<td><p><strong>
<select name="stime" id="stime">
<?php
$i=0;
while($i<24){
if($_POST['submitted'] == true){
if($_POST['stime']==$time[1][$i]){
echo "<OPTION VALUE='".$time[1][$i]."' selected>".$time[0][$i]." </OPTION>";
}
else{
echo "<OPTION VALUE='".$time[1][$i]."'>".$time[0][$i]." </OPTION>";
}
}
else {
echo "<OPTION VALUE='".$time[1][$i]."'>".$time[0][$i]." </OPTION>";
}
$i = $i+1;
}
?>
</select>
</strong></p>
<p>
<select name="etime" id="etime">
<?php
$i=0;
while($i<24){
if($_POST['submitted'] == true){
if($_POST['etime']==$time[1][$i]){
echo "<OPTION VALUE='".$time[1][$i]."' selected>".$time[0][$i]." </OPTION>";
}
else{
echo "<OPTION VALUE='".$time[1][$i]."'>".$time[0][$i]." </OPTION>";
}
}
else {
echo "<OPTION VALUE='".$time[1][$i]."'>".$time[0][$i]." </OPTION>";
}
$i = $i+1;
}
?>
</select>
</p>
<p><strong>
<select name="Branch" id="Branch">
<?php
$locations = array(array("Arlington","Richardson","North Houston", "San Antanio", "South Houston"),
array("47","3","305","1","2"));
$i=0;
while($i<5){
if($_POST['submitted'] == true){
if($_POST['Branch']==$locations[1][$i]){
echo "<OPTION VALUE='".$locations[1][$i]."' selected>".$locations[0][$i]." </OPTION>";
}
else{
echo "<OPTION VALUE='".$locations[1][$i]."'>".$locations[0][$i]." </OPTION>";
}
}
else {
echo "<OPTION VALUE='".$locations[1][$i]."'>".$locations[0][$i]." </OPTION>";
}
$i = $i+1;
}
?>
</select>
</strong></p>
<p>
<select name="Hours" id ="Hours">
<?php
$hours_array = array(array("All Employees","Less than 40 hours"),
array(">0","<40"));
$i=0;
while($i<2){
if($_POST['submitted'] == true){
if($_POST['Hours']==$hours_array[1][$i]){
echo "<OPTION VALUE='".$hours_array[1][$i]."' selected>".$hours_array[0][$i]." </OPTION>";
}
else{
echo "<OPTION VALUE='".$hours_array[1][$i]."'>".$hours_array[0][$i]." </OPTION>";
}
}
else {
echo "<OPTION VALUE='".$hours_array[1][$i]."'>".$hours_array[0][$i]." </OPTION>";
}
$i = $i+1;
}
?>
</select>
</p></td>
</tr>
</table>
<table width="1691" border="0">
<tr>
<td width="585" height="74"> </td>
<td width="109"><p>
<input type="submit" name="Submit" id="Submit" value="Submit" onClick="searchAction()" />
</p></td>
<td width="983"><label><strong>Send Message<br>
</strong>
<textarea name="Message" id="Message"></textarea>
<input type="submit" name="Send" id="Send" value="Send" onClick="sendMsg()" />
<input type="hidden" name="submitted" id="submitted" value="true" />
<br>
</label></td>
</tr>
</table>
<p> </p>
<table width="100%" border="0">
<td width="10%"> </td>
<td width="20%"><strong>Employee Name</strong></td>
<td width="15%"><strong>Home City</strong></td>
<td width="5%"><strong>State</strong></td>
<td width="20%"><strong>Cellphone</strong></td>
<td width="30%"><strong>Hours Worked</strong></td>
</tr>
<tr>
<p>
<?php
if($action =="search"){
//echo "hi";
$day = $_POST['Day'];
$month = $_POST['Month'];
$year = $_POST['Year'];
$stime = $_POST['stime'];
$etime = $_POST['etime'];
$branch = $_POST['Branch'];
$hours = $_POST['Hours'];
$query = "Select employee_id, employee_first_name, employee_last_name, employee_city, employee_state, employee_phone from champion_db.employee where employee_is_deleted = 0 and branch_id = '". $branch . "' ORDER by employee_first_name";
$result = pg_query($query);
$count = pg_num_rows($result);
//echo "count is".$count;
if (!$result) {
echo "Problem with query " . $query . "<br/>";
echo pg_last_error();
exit();
}
$width = 0; // the starting width
$percentage = 0; // the starting percentage
$width_per_iteration = 300 / $count; // how many pixels should the progress div be increased per each iteration
ob_start();
$date10 = mktime(0, 0, 0, $month, $day, $year);
$week = (string)date('W', $date10);
$year = (string)date ('Y', $date10);
$a = $year."W".$week;
$date11 =date('Y-m-d', $date10);
//echo "Date is". $date11;
//echo " Start time is ".$stime;
//echo " End time is ".$etime;
$b = date('Y-m-d', strtotime($a));
//echo "the first date" .$b;
//echo str_repeat('.', 256);
while($myrow = pg_fetch_assoc($result)) {
echo str_repeat(' ', 256);
if ($width < 295){
echo '<div class="progress_wrapper"><div class="progress" style="width:' . $width . 'px;"></div></div>';
$width += $width_per_iteration;
}
if ($width > 295)
{
echo '<div class="progress_wrapper2"><div class="progress2" style="width:350 px;"></div></div>';
}
ob_flush();
flush();
$empId = $myrow['employee_id'] ;
$firstName = $myrow['employee_first_name'];
$lastName = $myrow['employee_last_name'];
$city = $myrow['employee_city'];
$state = $myrow['employee_state'];
$phone = $myrow['employee_phone'];
$dates = array(date('Y-m-d', strtotime($a)), date('Y-m-d', strtotime($a."2")),date('Y-m-d', strtotime($a."3")),date('Y-m-d', strtotime($a."4")),date('Y-m-d', strtotime($a."5")),date('Y-m-d', strtotime($a."6")),date('Y-m-d', strtotime($a."7")));
$i=1;
$time = 0;
foreach ($dates as $date) {
$query_schedule = "Select employee_id, schedule_master_day, schedule_master_start, schedule_master_end, schedule_master_date_started, schedule_master_date_ended from champion_db.schedule_master where employee_id = ".$empId." and schedule_master_date_started < '". $date . "' and schedule_master_date_ended > '" . $date ."' and schedule_master_day = ".$i;
$i=$i+1;
$result_schedule = pg_query($query_schedule);
if (!$result_schedule) {
echo "Problem with query " . $query_schedule . "<br/>";
echo pg_last_error();
exit();
}
while($myrow_schedule = pg_fetch_assoc($result_schedule)) {
$start = $myrow_schedule['schedule_master_start'] ;
$end = $myrow_schedule['schedule_master_end'] ;
if($start > $end) {
$end = $end + 1440;
}
$minutes = $end - $start;
$m = $minutes % 60;
$h = ($minutes - $m) / 60;
if($m > 44 && $m < 60) {
$m = 75;
}
if($m > 29 && $m < 45) {
$m = 50;
}
if($m > 14 && $m < 30) {
$m = 25;
}
if($m > 0 && $m < 15) {
$m = 0;
}
$time = $time + (($h * 100) + $m) / 100;
}
}
//echo "time: ". $time . "<br/>";
$j=1;
foreach ($dates as $date) {
$query_sch = "Select employee_id, schedule_day, schedule_start, schedule_end, schedule_date from champion_db.schedule where employee_id = ".$empId." and schedule_date = '". $date . "' and schedule_day = ".$j;
$j=$j+1;
$result_sch = pg_query($query_sch);
if (!$result_sch) {
echo "Problem with query " . $query_sch . "<br/>";
echo pg_last_error();
exit();
}
while($myrow_sch = pg_fetch_assoc($result_sch)) {
$start = $myrow_sch['schedule_start'] ;
$end = $myrow_sch['schedule_end'] ;
//echo "Start2 is ".($start/60)*100 . "<br/>";
//echo "End2 is ".($end/60)*100 . "<br/>";
if($start > $end) {
$end = $end + 1440;
}
$minutes = $end - $start;
$m = $minutes % 60;
$h = ($minutes - $m) / 60;
if($m > 44 && $m < 60) {
$m = 75;
}
if($m > 29 && $m < 45) {
$m = 50;
}
if($m > 14 && $m < 30) {
$m = 25;
}
if($m > 0 && $m < 15) {
$m = 0;
}
$time = $time + (($h * 100) + $m) / 100;
}
}
if($hours == "<40"){
if($time < 40 && $time > 0) {
$result_count_master = pg_query("Select count(*) from champion_db.schedule_master where employee_id = ".$empId." and '".$date11."' between schedule_master_date_started and schedule_master_date_ended and schedule_master_start > ".$stime." and schedule_master_end < ".$etime );
$count_Master = pg_result($result_count_master, 0);
$result_count_sch = pg_query("Select count(*) from champion_db.schedule where employee_id = ".$empId." and schedule_date = '". $date . "' and schedule_start > ".$stime." and schedule_end < ".$etime);
$count_sch = pg_result($result_count_sch, 0);
$count = $count_Master + $count_sch;
//echo "count: ".$count;
if($count == 0){
echo "<tr>";
//echo $hours;
echo "<td><INPUT TYPE=CHECKBOX NAME='names[]' value=".$empId." ></td>";
echo "<td> " . $firstName . " " . $lastName . " </td>";
echo "<td> ". $city . "</td>";
echo "<td> ". $state . "</td>";
echo "<td> ". $phone . "</td>";
echo "<td> ". $time . "</td>";
echo "</tr>";
}
}
}
else {
if($time > 0) {
$result_count_master = pg_query("Select count(*) from champion_db.schedule_master where employee_id = ".$empId." and '".$date11."' between schedule_master_date_started and schedule_master_date_ended and schedule_master_start > ".$stime." and schedule_master_end < ".$etime );
$count_Master = pg_result($result_count_master, 0);
$result_count_sch = pg_query("Select count(*) from champion_db.schedule where employee_id = ".$empId." and schedule_date = '". $date . "' and schedule_start > ".$stime." and schedule_end < ".$etime);
$count_sch = pg_result($result_count_sch, 0);
$count = $count_Master + $count_sch;
//echo "count: ".$count;
if($count == 0){
echo "<tr>";
//echo $hours;
echo "<td><INPUT TYPE=CHECKBOX NAME='names[]' value=".$empId." ></td>";
echo "<td> " . $firstName . " " . $lastName . " </td>";
echo "<td> ". $city . "</td>";
echo "<td> ". $state . "</td>";
echo "<td> ". $phone . "</td>";
echo "<td> ". $time . "</td>";
echo "</tr>";
}
}
}
}
}
?>
<?php
if($action =="sendMsg"){
$connection2 = pg_connect("hostaddr=192.03.0.0 port=5432 dbname=uni user=post password=cst");
if (!$connection2) {
echo("Connection2 Failed.");
exit;
}
if (isset($HTTP_POST_VARS)) {
$names=$HTTP_POST_VARS["names"];
//echo("Names chosen: " . count($names) . "<br><br>");
//$phoneNumbers = array('ping.sumit@gmail.com');
$to = "ping.sumit@gmail.com";
for ($i=0; $i<count($names); $i++) {
//echo( ($i+1) . ") " . $names[$i] . "<br>");
$query_getId = "Select phone_number, carrier from employees where employee_id = ". $names[$i];
$result_getId = pg_query($query_getId);
while($myrow_getId = pg_fetch_assoc($result_getId)) {
$phoneNumber = $myrow_getId['phone_number'] ;
$carrier = $myrow_getId['carrier'] ;
if ($carrier == 'AT&T'){
//$phoneNumbers = "'". $phoneNumber . ".txt.att.net'";
$address = $phoneNumber."@txt.att.net";
$to = $to.", ".$address;
echo "Sent to" .$to;
}
}
}
ini_set("SMTP", "smtp.gmail.com");
$body = $_POST['Message'];
$headers = "From: uniquesecurity3@gmail.com";
$from = "uniquesecurity3@gmail.com";
$subject = "<Enter Subject>";
if(mail($to,$subject,$body,$headers, '-f ' . $from)){
echo "Message Sent Successfully";
} else{
echo "Message could not be Sent.";
}
}
}
?>
</table>
<p> </p>
<p> </p>
<p> </p></th>
</p>
</form>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</body>
</html>