<?php
session_start();
include("dbconnect.php");

	$school=0;
	$grade=0;
	$tchrID=0;
	$paName="";
	$paEmail="";
	$paPassword="";
	$paPhone="";
	$paCell="";

	$strSql2 = mysql_query("SELECT name,email,password,contact_no,cell_no FROM tr_parent where parent_id='".$_SESSION['pID']."'");
	$rsc2=@mysql_num_rows($strSql2);		
	if($rsc2>0)
	{
		$rs2=@mysql_fetch_array($strSql2);

		$paName=trim($rs2['name']);
		$paEmail=trim($rs2['email']);
		$paPassword=trim($rs2['password']);
		$paPhone=trim($rs2['contact_no']);
		$paCell=trim($rs2['cell_no']);
	}
	

	$strSql3 = mysql_query("SELECT syID FROM ma_schoolyear where sStatus=1 order by syID desc limit 1");
	$rsc3=@mysql_num_rows($strSql3);		
	if($rsc3>0)
	{
		$rsc3=@mysql_fetch_array($strSql3);
		 $yearRef=$rsc3['syID'];
	}

?>

<link rel="stylesheet" href="css/general.css" type="text/css" />
<div id="paEdAccount" style="background-color:#bcbbbb;" class="pEdAccount">
<form name='edparent' method='POST' action='edit_parent.php'>
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">
<tr><td colspan="3" valign="top" align="right">
<!-- <a class="deco" href="javascript:void(0)" onclick ="document.getElementById('paEdAccount').style.display='none';document.getElementById('fade').style.display='none'"><img src="images/btn_close.png" width="38" height="17" title="close" alt="close"/></a> -->
</td></tr>
	<tr><td></td><td colspan="2" class="fs14 onlines blue"><b><u>EDIT ACCOUNT</u></b></td></tr>
    <tr><td style="background-image:url('images/spacer.gif')" width="10"></td>
        <td width="350" valign="top">
            <table width="350" border="0" cellpadding="0" cellspacing="0">
                <tr><td style="background-image:url('images/spacer.gif')" width="150" height="10"></td><td style="background-image:url('images/spacer.gif')" width="200" height="10"></td></tr>
                <tr><td class="onlines blue">Parent/Guardian Name :</td><td><input type="text" id="paName" name="paName" class="formInput" maxlength="45" value="<?=$paName?>"/></td></tr>
                <tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr>
                <tr><td class="onlines blue">Your Email :</td><td><input type="text" id="paEmail" name="paEmail" class="formInput" maxlength="45" value="<?=$paEmail?>"/></td></tr>
                <tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr>
                <tr><td class="onlines blue">Your Password :</td><td><input type="password" id="paPassword" onKeyPress="pasChn()" name="paPassword" class="formInput" maxlength="15" value="<?=$paPassword?>"/></td></tr>
                <tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr>
                <tr><td colspan="2">
                        <table id="vPass" style="display:none" width="100%" cellpadding="0" cellspacing="0">
                            <tr><td width="150" class="onlines blue">Verify Your Password :</td><td width="200"><input type="password" id="pavPassword" name="pavPassword" class="formInput" maxlength="15" value="<?=$paPassword?>"/></td></tr>
                            <tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr>
                        </table></td></tr>
                <tr><td class="onlines blue">Phone No. :</td><td><input type="text" id="paPhone" name="paPhone" class="formInput" maxlength="15" value="<?=$paPhone?>"/></td></tr>
               	<tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr>
                <tr><td class="onlines blue">Cellphone No. :</td><td><input type="text" id="paCell" name="paCell" class="formInput" maxlength="15" value="<?=$paCell?>"/></td></tr>
            	<tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="10"></td></tr> 
				 <tr>
					<td align='center' colspan="2"><input type='submit' name='action' value='CHANGE'/></td>
				</tr> 

                <!-- <tr><td></td><td><a href="javascript:void(0)" onClick="updatePaAccnt(<?=$_SESSION['pID']?>)"><img src="images/change.gif" border="0" alt="change" title="change"/></a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick = "document.getElementById('paEdAccount').style.display='none';document.getElementById('fade').style.display='none'"><img src="images/cancel.gif" border="0" alt="cancel" title="cancel"/></a></td></tr> -->
                <tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr>
                <tr><td colspan="2" id="errpop" class="errmsg"></td></tr>
                <tr><td colspan="2" style="background-image:url('images/spacer.gif')" width="1" height="5"></td></tr> 
            </table></td>
       <!--  <td style="background-image:url('images/spacer.gif')" width="10" height="1"></td></tr> -->
</table>
</form>
</div>

<?php
if($_POST['action']=='CHANGE')
{
	$upd=@mysql_query("update tr_parent set Name='".$_POST['paName']."', email='".$_POST['paEmail']."', password='".$_POST['paPassword']."', contact_no='".$_POST['paPhone']."', cell_no='".$_POST['paCell']."', date_last_log='' where parent_id='".$_SESSION['pID']."'");

	echo '<script>';
	echo 'window.close()';
	echo '</script>';
}
?>