|
Posted by bulldog8 on 09/05/07 17:46
I have a web page set up for doctors to request vacation. All was
working well until they upgrade their home PCs to IE7, at which time
the variables lose their values when they click submit. We've allowed
cookies from this site and allowed JS to run in an attempt to fix the
issue, but no luck.
I use a javascript calendar and additional javascript to make sure the
end date > start date.
The user can still use the calendar tool to select dates and the js
still correctly ensures the end date and num of days requested fields
are populated correctly, so I am looking at my PHP code first.
Is there some error in my handling of session variables?
PHP code:
<?php
/**
* request.php
*
* Sends an email containing a vacation request and posts to database.
*
*/
session_start();
//Let's see if they want to go to another page first
if (strlen($btn) > 0) {
//save this pages info in case they come back
$rqst['Priority'] = $Priority;
$rqst['txtStartDate'] = $txtStartDate;
$rqst['txtEndDate'] = $txtEndDate;
$rqst['body'] = $body;
$rqst['txtNumReq'] = $txtNumReq;
$_SESSION['rqst'] = $rqst;
if (($btn == "recruit") || ($btn == "info")) {
<code removed for brevity
}
else {
require_once('../source/validate.php');
require_once('../fn/vac_data.php');
require_once('../cfg/config.php');
require_once('../fn/page_header.php');
//If they were here before lets get their input
if (isset($_SESSION['rqst'])) {
$rqst = $_SESSION['rqst'];
$Priority = $rqst['Priority'];
$txtStartDate = $rqst['txtStartDate'];
$txtEndDate = $rqst['txtEndDate'];
$body = $rqst['body'];
$txtNumReq = $rqst['txtNumReq'];
}
$vdays = 0;
if (!isset($_SESSION['vdays'])) {
$_SESSION['vdays'] = 0;
}
else {
unset($_SESSION['vdays']);
$_SESSION['vdays'] = 0;
}
$mailbox = 'INBOX';
if (isset($btnReset)) {
//Check to make sure this person is authorized
$imapConnection = fnimap_login($username, $key,
$imapServerAddress,$imapPort, 0);
$Priority = '1';
$txtStartDate = '';
$txtEndDate = '';
$body = '';
$txtNumReq = 0;
showInputForm();
fnimap_logout($imapConnection);
}
/* Send the Request */
elseif (isset($send)) {
if (checkInput(false)) {
$chkmsg = '';
$_SESSION['chkmsg']="";
$chkmsg = fnCheckDates(); //$vdays set in the fnCheckDates
function
if ($vdays < 0) {
showInputForm();
exit();
}
$urlMailbox = urlencode (trim($mailbox));
set_my_charset();
/* Format the & send message to include dates and priority
selections */
<<code removed for message brevity ...>
$Result = sendMessage($send_to, $send_to_cc, $send_to_bcc,
$subject, $comment, $reply_id, $MDN,
$mailprio);
}
if (! $Result) {
showInputForm();
exit();
}
//Call MySQL function to save data
$Result = saveVac($txtStartDate, $txtEndDate, $Priority,
$vdays, $body);
if (! $Result) {
showInputForm();
exit();
}
Header("Location: request.php?mail_sent=yes");
} else {
checkInput(true);
showInputForm();
}
} else {
/*
* This handles the default case as well as the error case
* (they had the same code) --> if (isset($smtpErrors))
*/
$imapConnection = fnimap_login($username, $key, $imapServerAddress,
$imapPort, 0);
$newmail = true;
showInputForm();
fnimap_logout($imapConnection);
}
}
exit();
function showInputForm () {
global $send_to, $send_to_cc, $body, $subject, $org_logo,
$btn, $txtStartDate, $txtEndDate, $Priority, $txtNumReq, $chkmsg,
$reply_id, $mailbox, $User_Name, $vdays, $prefs_are_cached,
$username, $data_dir, $default_sendto, $oncall,
$oncall_cnt,
$mailprio, $default_use_mdn, $mdn_user_support,
$compose_new_win,
$mail_sent, $this_yr, $next_yr, $cur_p1, $cur_p2, $cur_p3,
$next_p1, $next_p2, $next_p3;
$btn = '';
$User_Name = getPref($data_dir, $username, 'User_Name');
$subject = 'Vacation request for ' . $User_Name;
$send_to = $default_sendto;
$send_to_cc = getPref($data_dir, $username,'CC_Reply_to', 0);
if ($Priority == '') {
$Priority = '1';
}
if ($txtStartDate == '') {
$txtStartDate = date("m/d/Y");
}
if ($txtEndDate=='') {
$txtEndDate = date("m/d/Y",strtotime("1
days",strtotime($txtStartDate)));
}
if ($txtNumReq=='') {
$txtNumReq = 0;
}
$MyName = "request";
$Cal = 1;
$Oncall = 0;
$RTE = 0;
$Title = "Vacation Request";
displaytxan_header($MyName, $User_Name, $Cal, $Title, $Oncall,
$RTE);
if ($mail_sent == 'yes') {
echo '<BR><CENTER><B>'. _("Your Request has been sent").'</
CENTER></B>';
}
if ($vdays < 0) {
echo '<BR><CENTER><B>'. $chkmsg . '</CENTER>';
echo '<CENTER>Check available days and resubmit</CENTER></B>';
}
echo "<table border=\"3\" cellpadding=\"5\" cellspacing=\"4\"
width=\"100%\" height=\"16\"
bordercolorlight=\"#FFFFFF\" bordercolordark=\"#FFFFFF\">
<tr>
<td width=\"100%\" colspan=\"2\" height=
\"43\"><u><b>Vacation Request</b></u></td>
</tr>
<tr>
<td width=\"60%\" height=\"81\">
<p align=\"left\" style=\"margin-left: 30; margin-top:
1; margin-bottom: 1\">
Start Date <input type=\"text\" name=txtStartDate
id=txtStartDate size=\"20\" tabindex=\"1\" value=\"" .
$txtStartDate ."\">
<A HREF=\"#\" onClick=
\"cal5.select(document.forms['request'].txtStartDate,'anchor5','MM/dd/
yyyy'); return false;\"
TITLE=\"cal5.showCalendar('anchor5'); return false;\"
NAME=\"anchor5\" ID=\"anchor5\"><img src=\"../img/cal.gif\"
width=\"16\" height=\"16\" border=\"0\" alt=\"Pick Start date\"></
A><br></p>
<p align=\"left\" style=\"margin-left: 30; margin-top:
1; margin-bottom: 1\">
End Date <input type=\"text\" name=txtEndDate
id=txtEndDate size=\"20\" tabindex=\"2\" value=\"" . $txtEndDate ."\">
<A HREF=\"#\" onClick=
\"cal6.select(document.forms['request'].txtEndDate,'anchor5','MM/dd/
yyyy');; return false;\"
TITLE=\"cal6.showCalendar('anchor6'); return false;\"
NAME=\"anchor6\" ID=\"anchor6\"><img src=\"../img/cal.gif\"
width=\"16\" height=\"16\" border=\"0\" alt=\"Pick End date\"></
A><br></p>
Days Requested: <input type=\"text\" name=
\"txtNumReq\" id=\"txtNumReq\" size=\"20\" value=\"" .
$txtNumReq ."\">
</td>";
if (!isset($this_yr)) {
$this_yr = date("Y");
session_register('this_yr');
$next_yr = $this_yr + 1;
session_register('next_yr');
}
$prefs_are_cached = FALSE;
cachePrefValues($data_dir, $username);
$cur_p1 = getPref($data_dir, $username,'Cur_P1', 0);
$cur_p2 = getPref($data_dir, $username,'Cur_P2', 0);
$cur_p3 = getPref($data_dir, $username,'Cur_P3', 0);
$next_p1 = getPref($data_dir, $username,'Next_P1', 0);
$next_p2 = getPref($data_dir, $username,'Next_P2', 0);
$next_p3 = getPref($data_dir, $username,'Next_P3', 0);
echo " <td width=\"40%\" height=\"79\" nowrap valign=\"top\"
bordercolor=\"#000000\" rowspan=\"2\">
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\"><u>Vacation Days Remaining :</u></p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\"> </p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\"><u>" . $this_yr . "</u></p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\">Priority 1 " . $cur_p1 . "</p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\">Priority 2 " . $cur_p2 . "</p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\">Priority 3 " . $cur_p3 . "</p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\"> </p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\"><u>" . $next_yr . "</u></p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\">Priority 1 " . $next_p1 . "</p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\">Priority 2 " . $next_p2 . "</p>
<p style=\"margin-left: 50; margin-top: 1; margin-
bottom: 1\">Priority 3 " . $next_p3 . "</p>
<p> </p><p> </p></td>
</tr>";
echo " <tr><td width=\"60%\" height=\"1\">
<fieldset style=\"width: 117; height: 127; padding:
2\">
<legend>Priority</legend>
<input type=\"radio\" value=\"1\" name=\"Priority\"
tabindex=\"3\"" .($Priority == '1'?' checked ':'') . ">" .
_("Priority 1") . "
<p><input type=\"radio\" value=\"2\" name=\"Priority\"
tabindex=\"4\"" .($Priority == '2'?' checked ':''). ">" . _("Priority
2") . "</p>
<p><input type=\"radio\" value=\"3\" name=\"Priority\"
tabindex=\"5\"" .($Priority == '3'?' checked ':''). ">" . _("Priority
3") . "</p>
</fieldset>";
echo " <p style=\"word-spacing: 1; margin-left: 90; margin-
top: 1; margin-bottom: 1\"></p>
<p style=\"margin-left: 30; margin-top: 1; margin-
bottom: 1\"> </p>
<p align=\"left\" style=\"margin-left: 30; margin-top:
1; margin-bottom: 1\"></p>
<p align=\"left\" style=\"margin-left: 30; margin-top:
1; margin-bottom: 1\">Comments</p>
<p align=\"left\" style=\"margin-left: 30; margin-top:
1; margin-bottom: 1\">
<textarea rows=9 name=body tabindex=6 cols=59
WRAP=VIRTUAL> " . htmlspecialchars($body) . "</textarea></p>
<p align=\"left\"> </td></tr>
<tr><td width=\"100%\" height=\"1\" colspan=\"2\"
bordercolor=\"#FFFFFF\">
<input type=submit name=send value=\"" . _("Send") .
"\">
<input type=submit name=btnReset value=\"" . _("Reset
Form") . "\"></p>
<INPUT TYPE=hidden NAME=mailbox VALUE=\"" .
htmlspecialchars($mailbox) . "\">
<INPUT TYPE=hidden NAME=send_to VALUE=\"" .
htmlspecialchars($send_to) . "\">
<INPUT TYPE=hidden NAME=send_to_cc VALUE=\"" .
htmlspecialchars($send_to_cc) . "\">
<INPUT TYPE=hidden NAME=subject VALUE=\"" .
htmlspecialchars($subject) . "\">
<INPUT TYPE=hidden NAME=btn VALUE=\"" .
htmlspecialchars($btn) . "\">
</td>
</tr>
</table>
</FORM>
<DIV ID=\"testdiv1\" STYLE=
\"position:absolute;visibility:hidden;background-color:white;layer-
background-color:white;\"></DIV>";
echo "<script type=\"text/javascript\">
<!-- // create calendar object(s) just after form tag closed
// specify form element as the only parameter
(document.forms['formname'].elements['inputname']);
// note: you can have as many calendar objects as you need for
your application
var now = new Date();
var cal5 = new CalendarPopup(\"testdiv1\");
cal5.addDisabledDates(null,formatDate(now,\"yyyy-MM-dd\"));
//cal5.showNavigationDropdowns();
cal5.setCssPrefix(\"TEST\");
cal5.setReturnFunction(\"setStartDate\");
function setStartDate(y,m,d) {
document.forms['request'].txtStartDate.value=padDigit(m) + '/' +
padDigit(d) + '/' + y;
if (document.forms['request'].txtEndDate.value==''){
document.forms['request'].txtEndDate.value=dateAdd(d + '/' +
m +'/'+ y, 1);
document.forms['request'].txtNumReq.value=WeekDays(document.forms['request'].txtStartDate.value,document.forms['request'].txtEndDate.value);
}
else {
if
(DateDiff(document.forms['request'].txtStartDate.value,document.forms['request'].txtEndDate.value)
<0) {
document.forms['request'].txtEndDate.value=dateAdd(d + '/'
+ m +'/'+ y, 1); }
document.forms['request'].txtNumReq.value=WeekDays(document.forms['request'].txtStartDate.value,document.forms['request'].txtEndDate.value);
}
}
var cal6 = new CalendarPopup(\"testdiv1\");
cal6.addDisabledDates(null,formatDate(now,\"yyyy-MM-dd\"));
//cal6.showNavigationDropdowns();
cal6.setCssPrefix(\"TEST\");
cal6.setReturnFunction(\"setEndDate\");
function setEndDate(y,m,d) {
document.forms['request'].txtEndDate.value=padDigit(m) + '/' +
padDigit(d) + '/' + y;
document.forms['request'].txtNumReq.value=WeekDays(document.forms['request'].txtStartDate.value,document.forms['request'].txtEndDate.value);
}
// --></script>";
echo "<script type=\"text/javascript\">
function submitform(menutxt)
{
document.forms['request'].btn.value=menutxt;
document.forms['request'].submit();
}
</SCRIPT>";
echo '</body></HTML>';
}
[Back to original message]
|