<?php
include "chkuser.php";
include "includefilemng.php";
	
if (isset($_GET['editid']))
{
 $sqld = "SELECT * FROM subscribedusers where id= '$_GET[editid]'";
 $resultd = mysql_query($sqld,$eclipse); 
 $rowd = mysql_fetch_object($resultd);
}

if (isset($_POST['savegau']))
{
$proceed = 0;
//check if state exits in the DB
if ($_POST['email'] != $_POST['oldname'])
	{
		$query3="SELECT email FROM subscribedusers where email='$_POST[email]'";
		$result3=mysql_query($query3,$eclipse);
		$row3=mysql_num_rows($result3);
		if($row3 > 0)
		{
		$proceed = 1;
		}
		else
		{
		$proceed = 0;
		}
	}
	//if $proceed is < 1 then enter data
	if($proceed < 1)
	{
    $qid ="Update subscribedusers set email='$_POST[email]',name='$_POST[name]' where id='$_POST[id]'";					
	$updateresult = mysql_query($qid);
	header('Location: view_user.php?errormsg=Updated');
	}
	else
	{
	$rmsg = "The Email ".$_POST['email']." already exists";
	$edit = $_POST['id'];
		if (isset($edit))
		{
		$sqld = "SELECT * FROM subscribedusers where id= '$edit'";
		$resultd = mysql_query($sqld,$eclipse); 
		$rowd = mysql_fetch_object($resultd);
		}

	}

}
?>	
<html>
<head>
<title>control panel </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="ssi.css" rel="stylesheet" type="text/css">
<script language="javascript" src="includenp/functions.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript" src="tinymca.js"></script>	

<style type="text/css">
<!--
.style2 {color: #000000}
-->
</style>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td width="1%"   bgcolor="#C9C9C9"></td>
	<td width="98%"><?php include_once "top.php";?></td>
	<td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
   <td width="1%"   bgcolor="#C9C9C9"></td>
    <td width="98%"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="centertable">
      <tr>
        <td><table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="50" class="bigblackTxt">&nbsp;</td>
          </tr>
          <tr>
            <td class="errFont"><?php
		if(isset($rmsg))
		{echo display_error_msg($rmsg);
		   	}
		?></td>
          </tr>
          <tr>
            <td>
            
              <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="4">
                <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>" name="SaveForm" ID="SaveForm" enctype="multipart/form-data" >
                
				
                  <tr>
                    <td colspan="2" class="bigblackTxt"></td>
                  </tr>
				  <tr>
                    <td height="24" colspan="2" class="errFont"> * marked fields are mandatory </td>
                  </tr>
				  <tr>
                    <td colspan="2" class="normalBoldblackTxt"> Identification </td>
                  </tr>                 
                 
                   
                                        
				  <tr>
                    <td width="26%" class="bluebold"><span class="errFont">*</span>Name: </td>
                    <td width="74%"><input name="name" type="text" value="<?php echo $rowd->name;?>" size="30" id="name"></td>
                  </tr>
				  
				 
				  <tr>
                    <td width="26%" class="bluebold"><span class="bluebold"> <span class="errFont">*</span>Email:</span></td>
                    <td width="74%"><input name="email" type="text" id="email" value="<?php echo $rowd->email; ?>" size="30"></td>
                  </tr>
				
				  <tr>
                  <td class="bluebold">&nbsp;</td>
				    <td class="bluebold"><input name="oldname" type="hidden" id="oldname" value="<?php echo $rowd->email; ?>">
          <input name="id" type="hidden" id="id2" value="<?php echo $rowd->id; ?>"></td>
				    </tr>
				  <tr>
                    <td width="26%" class="bluebold">&nbsp;</td>
                    <td width="74%"><INPUT NAME="savegau" type="submit" class="bigblackTxt" ID="savegau"  value="UPDATE"></td>
                  </tr>
				  <tr>
                    <td align="right">&nbsp;</td>
                    <td>                      <span class="normalTxt"><span class="bigblackTxt">
                    
                      </span></span></td>
                  </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                  </tr>
                </form>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
  <tr>
    <td   bgcolor="#C9C9C9" width="1%"></td>
	<td><?php include_once "footer.php";?></td>
	<td width="1%"   bgcolor="#C9C9C9"></td>
  </tr>
</table>
</body>
</html>
