<?php 
session_start();
?>
<?php require_once('Connections/mycon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_Recordset1 = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_Recordset1 = $_SESSION['MM_Username'];
}
mysql_select_db($database_mycon, $mycon);
$query_Recordset1 = sprintf("SELECT * FROM card WHERE pinno = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $mycon) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['pinno'])) {
  $loginUsername=$_POST['pinno'];
  $password=$_POST['serial'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "showresulttPri.php";
  $MM_redirectLoginFailed = "invalidcard.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_mycon, $mycon);
  
  $LoginRS__query=sprintf("SELECT pinno, serial, login_nos, sno FROM card WHERE pinno=%s AND serial=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $mycon) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  $row = mysql_fetch_assoc($LoginRS);
$pinno = $row['pinno'];
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
	// Insert login count into database

mysql_query('UPDATE card

SET login_nos = login_nos + 1 WHERE pinno = '.$pinno.'')

or die(mysql_error());

    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['pinno'])) {
  $loginUsername=$_POST['pinno'];
  $password=$_POST['serial'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "recheckconttPri.php";
  $MM_redirectLoginFailed = "invalidcard.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_mycon, $mycon);
  
  $LoginRS__query=sprintf("SELECT pinno, serial FROM card WHERE pinno=%s AND serial=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $mycon) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!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>
<meta http-equiv="Refresh" content="3" />
<meta http-equiv="Refresh" content="3" />
<head>
<script language="JavaScript" type="text/javascript">
var t = setTimeout("document.form1.submit();",2000); //2 seconds measured in miliseconds
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to Primary School Result Portal</title>
<style type="text/css">
#header {
	background-color: #990099;
	height: 124px;
	width: auto;
	margin-bottom: 15px;
	text-align: center;
}
#INSIDEE {
	height: 80px;
	width: 1000px;
	margin-right: auto;
	margin-left: auto;
}
#newlogo {
	float: left;
	height: 124px;
	width: 100%;
	text-align: left;
	background-color: #909;
}
#name {
	width: 100px;
	float: left;
}
#menu {
	background-color: #EA9282;
	height: 30px;
	width: 900px;
	margin-right: auto;
	margin-left: auto;
	margin-bottom: 40px;
}
#marq {
	height: 40px;
	width: 900px;
	margin-right: auto;
	margin-left: auto;
	margin-bottom: 8px;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: dotted;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
}
#INNNNN {
	height: 30px;
	width: 900px;
	margin-right: auto;
	margin-left: auto;
}
body {
	background-color: #F0F0F0;
}
#wrapper {
	width: 900px;
	margin-right: auto;
	margin-left: auto;
	height: 380px;
	margin-bottom: 10px;
}
#L {
	float: left;
	height: 150px;
	width: 300px;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: dotted;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
}
#M {
	height: 150px;
	width: 290px;
	float: left;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: dotted;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
	text-align: center;
}
#R {
	float: right;
	height: 150px;
	width: 300px;
	text-align: center;
}
#logo {
}
#subfooter {
	width: 900px;
	margin-right: auto;
	margin-left: auto;
	height: 150px;
	clear: both;
	border-top-width: 10px;
	border-top-style: ridge;
	border-right-width: thin;
	border-bottom-width: thin;
	border-left-width: thin;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
}
#fotter {
	width: 900px;
	margin-right: auto;
	margin-left: auto;
	background-color: #6CF;
	text-align: center;
}
#logo {
	width: 90px;
	margin-left: 200px;
	float: left;
}
#wa {
	width: 900px;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: dotted;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
	text-align: center;
	height: 380px;
	margin-right: auto;
	margin-left: auto;
}
#wb {
	float: right;
	width: 390px;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: dotted;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
	height: 380px;
}
#wrapper #wb table {
	font-size: 12px;
}
#UP {
	height: 198px;
	width: 390px;
	border-bottom-width: 1px;
	border-bottom-style: dashed;
	border-top-width: 1px;
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: dashed;
	border-right-style: dashed;
	border-left-style: dashed;
	text-decoration: none;
}
#dowm {
	height: 380px;
	width: 390px;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: dotted;
	border-right-style: dotted;
	border-bottom-style: dotted;
	border-left-style: dotted;
}
#newname {
	float: left;
	height: 80px;
	width: 370px;
}
#CONTACTT {
	float: right;
	height: 128px;
	width: 400px;
	text-align: center;
}
.style10 {font-size: 36px;
	font-weight: bold;
}
.style11 {color: #FFFFFF}
</style>
<link href='menus/138/menu138id29_style.css' rel='stylesheet' type='text/css' />
<link href='menus/138/menu138id35_style.css' rel='stylesheet' type='text/css' />
</head>

<body>
<div id="header">
  <div id="newlogo">
    <div align="center" class="style10"><img src="Vg Schools Logo.jpg" alt="Victory School Logo" width="122" height="117" align="middle" /> <span class="style11">Victory Early Learning Centre &amp; Victory College Int'l </span><br />
    </div>
  </div>
</div>
<div id="wrapper">
  <div id="wa">
    <p><br />
    </p>
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
      <br />
      &nbsp;&nbsp;&nbsp;<span style="color: #F00; font-family: Tahoma, Geneva, sans-serif;">&nbsp;&nbsp;Wait, result loading......</span></p>
    <form id="form1" name="form1" method="post" action="<?php echo $loginFormAction; ?>">
      <p>
        <input name="pinno" type="hidden" id="pinno" value="<?php echo $_SESSION['pinno']; ?>" />
        <label for="serial"></label>
        <input name="serial" type="hidden" id="serial" value="<?php echo $_SESSION['serial']; ?>" />
        <input name="idno" type="hidden" id="idno" value="<?php echo $_SESSION['idno']; ?>" />
        <input name="semester" type="hidden" id="semester" value="<?php echo $_SESSION['semester']; ?>" />
        <input name="session" type="hidden" id="session" value="<?php echo $_SESSION['session']; ?>" />
        <input name="button" type="hidden" id="button" value="YES ! SHOW MY RESULT" />
      </p>
    </form>
    <p>&nbsp;</p>
  </div>
</div>
<div align="center" class="style13">
  <div align="center">
    <p>Copyright ©2014-2018 VIctory School Int'l, Aba ::: All Rights Reserved </p>
    <p><a href="https://dataswiftlimited.com" target="_blank"><img src="https://dataswiftlimited.com/datalogo.jpg" alt="DataSwift Designs" width="123" height="63" border="0" longdesc="https://dataswiftlimited.com" /></a></p>
  </div>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
