Log in

View Full Version : Form error return



neeraj
02-06-2010, 03:14 PM
I have a page which consists of 3 divs, that are hidden/unhidden based on user selection. On first div, I am displaying the user data. On second div the user can modify user data. And in third div the user can change the password.

First div is displayed as default and second & third divs are shown/hidden based on the what the user selects.

The problem I'm facing is that whenever the user updates it's password and any of the entry is wrong, even thought this page is displayed but the first div is shown [by default] not the password change div. Is there any way of returning to page with third div visible ?

My page code is below:


<?php
include("includes/session.php");
if($session->logged_in){
include("includes/header.php");

$user_name = get_current_user_name($usr);
$user_details = get_current_user_details($usr);
?>
<script language="JavaScript">
<!--

function show(menuName) {
var el = document.getElementById(menuName);
el.style.display = 'block';
}

function hide(menuName) {
var el = document.getElementById(menuName);
el.style.display = 'none';
}
//-->
</script>

<div class="page">
<div class="post">
<div id="first">
<h2>Account Details for <?php echo $user_name; ?></h2>
<table id="usr_details_no_edit">
<tr class="headings"><td colspan="2">Official Information</td></tr>
<?php
while ( $row = mysql_fetch_array ( $user_details ) ) { ?>
<tr><td width="40%">Employee ID</td><td><?php echo $row['emp_id']; ?></td></tr>
<tr><td>Designation</td><td><?php echo $row['emp_designation']; ?></td></tr>
<tr><td>Date of Birth</td><td><?php echo $row['emp_dob']; ?></td></tr>
<tr><td>Joining Month-Year</td><td><?php echo $row['emp_doj']; ?></td></tr>
<tr><td>Emai ID</td><td><?php echo $row['emp_email']; ?></td></tr>
<?php
}
?>
</table>
<br />
<table id="usr_details_edit">
<tr class="headings"><td colspan="2">Personal Information</td></tr>
<?php
$user_details = get_current_user_details($usr);
while ( $row2 = mysql_fetch_array ( $user_details ) ) { ?>
<tr><td width="40%">Extension Number</td><td><?php echo $row2['emp_desk_num']; ?></td></tr>
<tr><td>Mobile Number</td><td><?php echo $row2['emp_mobile']; ?></td></tr>
<tr><td>Residence Number</td><td><?php echo $row2['emp_home']; ?></td></tr>
<?php
}
?>
</table>
<table id="leaves_tbl">
<tr><td align="right"><a href="#" class="button" onclick="show('second'); hide('first'); hide('third');" title="Modify personal details">Modify</a></td>
<td width="120px" align="right"><a href="#" class="button" onclick="show('third'); hide('first'); hide('second');" title="Change Password">Password</a></td>
<td width="120px" align="right"><a href="index.php" class="cancel_button" title="Cancel">Cancel</a></td>
</table>
</div>
<div id="second" style="display: none;">
<h2>Modify user details</h2>
<form action="user_functions.php?type=new" method="post" name="leave_input" id="inputArea">
<table id="tipsntricks">
<?php
$user_details = get_current_user_details($usr);
while ( $row2 = mysql_fetch_array ( $user_details ) ) { ?>
<tr><td width="40%">Extension Number</td><td><input name="emp_desk_num" type="text" size="10" value="<?php echo $row2['emp_desk_num']; ?>" tabindex="1" /></td></tr>
<tr><td>Mobile Number</td><td><input name="emp_mobile" type="text" size="10" value="<?php echo $row2['emp_mobile']; ?>" tabindex="2" /></td></tr>
<tr><td>Residence Number</td><td><input name="emp_home" type="text" size="10" value="<?php echo $row2['emp_home']; ?>" tabindex="3" /></td></tr>
<?php
}
?>
</table>
<table id="leaves_tbl">
<tr><td align="right"><a href="#" class="button" onclick="show('second'); hide('first'); hide('third');" title="Submit">Submit</a></td>
<td width="120px" align="right"><a href="#" class="cancel_button" onclick="show('first'); hide('second');" title="Cancel">Cancel</a></td>
</table>
</form>
</div>
<div id="third" style="display: none;">
<h2>Change Password</h2>
<form action="process.php" method="post" name="change_pwd" id="inputArea">
<table id="tipsntricks">
<tr><td width="40%">Current Password</td><td><input name="curpass" type="password" value="<?echo $form->value("curpass"); ?>" tabindex="1"/><? echo $form->error("curpass"); ?></td></tr>
<tr><td>New Password</td><td><input name="newpass" type="password" value="<? echo $form->value("newpass"); ?>" tabindex="2" /><? echo $form->error("newpass"); ?></td></tr>
</table>
<table id="leaves_tbl">
<tr><td><input type="hidden" name="subedit" value="1"></td>
<td width="120px" align="right"><a href="#" class="button" onclick="javascript:document.change_pwd.submit(); " title="Submit">Submit</a></td>
<td width="120px" align="right"><a href="#" class="cancel_button" onclick="show('first'); hide('second'); hide('third');" title="Cancel">Cancel</a></td>
</table>
</form>
</div>
</div>
<?php
include("$site_root/includes/footer.php");
} else {
header("Location: login.php");
exit;
}
?>

div id third is the one containing the form for changing password.