<?php
 session_start();
 include ("emenu1.php"); 
 require ("conecta.php");
 $nick=$_POST['nick'];
 $password=$_POST['password'];
 $tusu=$_POST['hdtusu'];
 $sw=$_POST['hdsw'];
 if ($sw=="grabar"){
  $nick=$_POST['nick'];
  $password=$_POST['password'];
  $tusu=$_POST['hdtusu'];
  $sqlbusca="select * from m06006 where nick='$nick' and password='$password';";
  $resbusca=mysql_query($sqlbusca,$con);
  if (mysql_num_rows($resbusca)==0){
   $sqlgraba="insert into m06006 
   (nick,password,cod_t_usu)
   values ('$nick','$password','$tusu');";
   $resg=mysql_query($sqlgraba,$con) ;
   }//fin si busca
  $sw="";
  $nick="";
  $password="";
  $tusu="";
}//fin grabar
if ($sw=="eliminar"){
 $nick=$_POST['nick'];
 $password=$_POST['password'];
 $tusu=$_POST['hdtusu'];
 $sqlel="delete from m06006 where nick='$nick' and password='$password';";
 $resel=mysql_query($sqlel,$con);
 $sw="";
 $nick="";
 $password="";
 $tusu="";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>Login</TITLE>
<script language="javascript" src="fstandar.js"></script>
<script language="javascript">
function poneusuario(){
 document.form1.hdtusu.value=document.form1.tipousu.value;
 window.alert(document.form1.hdtusu.value);
 }
function grabar(){
 err=0;
 var uno=new String("");
 uno=document.form1.tipousu.options[document.form1.tipousu.selectedIndex].text;
 errd="";
 if (uno.substr(uno,5)=="Selec"){
  err=1;
  errd+="\n -> Usuario";
 }
 if (err==0){//si*
  document.form1.hdsw.value="grabar";
  document.form1.action="M0601006.php";
  document.form1.method="post";
  document.form1.submit();
 }else{
  window.alert("Debe seleccionar: " + errd);
 }//fin si*  
}//fin grabar
function eliminar(){
 if (window.confirm("seguro desea eliminar")==true){//si 1
  err=0;
  var uno=new String("");
  uno=document.form1.tipousu.options[document.form1.tipousu.selectedIndex].text;
  errd="";
  if (uno.substr(uno,5)=="Selec"){
   err=1;
   errd+="\n ->> Usuario";
  }
  if (err==0){//si*
   document.form1.hdsw.value="eliminar";
   document.form1.action="M0601006.php";
   document.form1.method="post";
   document.form1.submit();
  }else{
   window.alert("Debe seleccionar: " + errd);
  }//fin si*   
 }//fin si 1
}//fin eliminar 
</script>
<link rel="stylesheet" href="styles.css">
<style type="text/css">
<!--
.Estilo1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
</HEAD>
<BODY>
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=center align=middle height="100%">
      <TABLE height=400 cellSpacing=0 cellPadding=0 width=718 border=0>
        <TBODY>
        <TR>
          <TD width="718" height=22>
            <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" 
              border=0><TBODY>
              <TR>
                <TD vAlign=top align=left width=24><A 
                  href="index.php"><IMG src="images/xc_left.gif" alt="Inicio" width=24 
                  height=22 
                  border=0></A></TD>
                <TD vAlign=top align=left width="100%"><IMG height=22 
                  src="images/xc_center.gif" width="100%" 
                border=0></TD>
              <TD vAlign=top align=right width=24><IMG height=22 
                  src="images/xc_right.gif" width=24 
              border=0></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=BottomTable vAlign=top 
          background=images/xc_stripes.gif height="100%">
            <TABLE class=IconsTable height=33 cellSpacing=0 cellPadding=0 
            width="100%" border=0>
              <TBODY>
              <TR>
                <TD height="32"><div align="right" class="larger">
                  <div align="right">Vemol</div>
                </div></TD>
                </TR></TBODY></TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="715" 
              border=0>
              <TBODY>
              <TR>
                <TD width=23 height=18>&nbsp;</TD>
                <TD vAlign=top align=left width=180 height=18>&nbsp;</TD>
                <TD width=12 height=18>&nbsp;</TD>
                <TD width="461" height=18 class=MainMenuHead>Usuarios:</TD>
                <TD width=20 height=18>&nbsp;</TD></TR>
              <TR>
                <TD width=23 height="100%">&nbsp;</TD>
                <TD vAlign=top align=left width=180 height="100%">
                  <TABLE cellSpacing=0 cellPadding=0 width="150" border=0>
                    <TBODY>
                    <TR>
                      <TD width=10><IMG height=12 
                        src="images/xc_dotgrey.gif" width=10></TD>
                      <TD width=4>&nbsp;</TD>
                      <TD class=LeftMenu noWrap>Ingreso al sistema.</TD>
                    </TR>
                    <TR>
                      <TD width=10><IMG height=12 
                        src="images/xc_dotgrey.gif" width=10></TD>
                      <TD width=4>&nbsp;</TD>
                      <TD class=LeftMenu noWrap>Logeo de usuarios registrados. </TD>
                    </TR>
                    <TR>
                      <TD width=10 valign="top"><IMG height=12 
                        src="images/xc_dotgrey.gif" width=10></TD>
                      <TD>&nbsp;</TD>
                      <TD class=LeftMenu noWrap>Alertas:<br />
                        <span class="Estilo1">
                        <?php 
							     echo $_SESSION['msglog'];
								 $_SESSION['msglog']="";
								 ?>
                        </span></TD>
                    </TR></TBODY></TABLE></TD>
                <TD width=12 height="100%">&nbsp;</TD>
                <TD class=contentcell vAlign=top align=middle width=461 
                height="100%">
                  <TABLE width="100%">
                    <TBODY>
                    <TR>
                      <TD>
                        <form name="form1" method="post" action="entrada.php">
                          <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <th width="49%" scope="col"><div align="right" class="Emphasize">Nick:</div></th>
                              <th width="51%" scope="col"><div align="left">
                                <label>
                                <input name="nick" type="text" id="nick" value="<?php echo $nick ?>" size="11" maxlength="10" />
                                </label>
                              </div></th>
                            </tr>
                            <tr>
                              <th scope="row"><div align="right" class="Emphasize">Password:</div></th>
                              <td><label>
                                <input name="password" type="password" id="password" value="<?php echo $password ?>" size="11" maxlength="10" />
                              </label></td>
                            </tr>
                            <tr>
                              <th scope="row"><div align="right" class="Emphasize"></div></th>
                              <td><div align="left" class="Estilo1"></div></td>
                            </tr>
                            <tr>
                              <th scope="row">&nbsp;</th>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <th colspan="2" scope="row"><input name="cmding" type="submit" id="cmding" value="Ingresar" onclick="grabar()" />
                                <label></label>
                                &nbsp;&nbsp;
                                <label></label>
                                <label></label>                                
                                <label></label>
                                &nbsp;&nbsp;
								<input name="cmdlim" type="reset" id="cmdlim" value="Limpiar" onclick="eliminar()"/>								</th>
                              </tr>
                          </table>
                                </form>						</TD>
                    </TR></TBODY></TABLE></TD>
                <TD width=20 height="100%">&nbsp;</TD></TR>
              <TR>
                <TD width=23 height=8>&nbsp;</TD>
                <TD width=180 height=8>&nbsp;</TD>
                <TD width=12 height=8>&nbsp;</TD>
                <TD width="461" height=8>&nbsp;</TD>
        <TD width=20 
      height=8>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY>
<!-- /Footer -->
<script language="JavaScript" src="menu.js"></script>
<script language="JavaScript" src="menu_tpl.js"></script>
<script language="JavaScript">
	new menu (MENU_ITEMS, MENU_POS);
</script>
	  </TABLE>
	</BODY>
<?php
	mysql_close($con);
?>
</HTML>