<? 
session_start();

$validpwd = true;
if (isset($_POST["apellido"])) {
	// setup variables
	$userid=$_POST["apellido"];
	$passwd=$_POST["email"];

  
	$servername = "localhost";
	$username = "contraz9_sql";
	$password = "yov929jsns";
	$dbname = "contraz9_FM";

	// Create connection
	$conn = new mysqli($servername, $username, $password, $dbname);
	// Check connection
	if ($conn->connect_error) {
		die("Connection failed: " . $conn->connect_error);
	} 

	$sql = "Select * from Suscriptores where Apellido = '".strtoupper($userid)."'";
	//echo $sql;
	$result = $conn->query($sql);

	if ($result->num_rows > 0) {
		// output data of each row
		while($row = $result->fetch_assoc()) {
			if (strtoupper($row["Email"]) == strtoupper($passwd)) {
			  $validpwd=true;
			}
			else {
			  $validpwd=false;
			}
		}
	} else {
		$validpwd = false;
	}
	$conn->close();
  
	if ($validpwd) {
		
		$_SESSION["status"] = "login";
		header("Location: https://issuu.com/ndiricci/docs/fm89");
	}
	
}
?>
<html>
<head>
<title>Facility Magazine</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-208213-1', 'auto');
  ga('send', 'pageview');

</script>
<script language="JavaScript">

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
//-->
</script>
<link rel="stylesheet" href="css/fm.css" type="text/css">
<style type="text/css">
<!--
-->
</style>
</head>
<body leftmargin="0" topmargin="0">
  <table height="760" id="sectable"  cellpadding="0"  cellspacing="0">
    <tr>
  <td valign="top">
  <FORM method="post" action="e-online.asp" name="e-online" target="_blank">
    <table width="655" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="4" rowspan="35" valign="bottom"><img height="1" width="2" src="/spacer.gif"></td>
        
      </tr>
      <tr>
        <td colspan="7" class="espacio">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="7" valign="bottom" class="subtitulos">
          <div align="center">
            <p>
          Si ya ha registrado sus datos en el formulario de Suscripciones, ingrese su apellido y su email para acceder a la edici&oacute;n on line.<br>
          Si a&uacute;n no lo ha hecho, reg&iacute;strese ahora ingresando en <a href="suscripciones.asp">Suscripciones</a></p>
            <table width="200" cellspacing="0" cellpadding="0">
              <tr>
                <th width="40" class="subtitulos" scope="row">Apellido</th>
                <td width="4">&nbsp;</td>
                <td colspan="2"><input type="text" name="apellido" size="50" class="box"></td>
              </tr>
              <tr>
                <th scope="row">&nbsp;</th>
                <td>&nbsp;</td>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <th class="subtitulos" scope="row">E-mail</th>
                <td>&nbsp;</td>
                <td colspan="2"><input type="text" name="email" size="50" class="box"></td>
              </tr>
              <tr>
                <th scope="row">&nbsp;</th>
                <td>&nbsp;</td>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <th scope="row">&nbsp;</th>
                <td>&nbsp;</td>
                <td colspan="2"><? if (!$validpwd) { ?>
                    <font color="#FF0000" class="Error"><b>Apellido o E-mail incorrectos, vuelva a intentarlo</b></font></td>
              </tr>
              <tr>
                <th scope="row">&nbsp;</th>
                <td>&nbsp;</td>
                <td colspan="2"><? } ?></td>
              </tr>
              <tr>
                <th scope="row">&nbsp;</th>
                <td>&nbsp;</td>
                <td width="111"><div align="right">
                  <input type="submit" name="Submit" value="acceder" class="boton">
                </div></td>
                <td width="89">
                    <div align="left">
                      <input type="reset" name="reset" value="borrar" class="boton">
                    </div></td>
              </tr>
            </table>
            <div align="right"></div>
            <p>&nbsp;</p>
        </div></td>
      </tr>
      
        <td valign="bottom" class="subtitulos" colspan="2">&nbsp;</td>
        <td valign="bottom" class="subtitulos" width="70">&nbsp;</td>
        <td valign="bottom" class="subtitulos" width="87">&nbsp;</td>
      </tr>
      <tr>
        <td width="83"></td>
        <td width="21"></td>
        <td width="70"></td>
        <td width="87"></td>
        <td width="4"></td>
        <td width="4"></td>
        <td width="304"></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
    </table>
  </FORM>  </td>

    </tr>
</table>
</div>
<div align="center"></div>
</body>
</html>
