<?php

session_start();

require("./ninsyou.inc");

echo "<html>";
echo "<body>";

$namae = $_POST['namae'];
$pass = $_POST['pass'];

if(!isset($namae) || !isset($pass)){
   echo "data not set err.";
   exit();
   }

if(0 != strcmp("ASCII", mb_detect_encoding($namae))){
   echo "user name encode err. not ascii.";
   exit();
   }

if(0 != strcmp("ASCII", mb_detect_encoding($pass))){
   echo "password encode err. not ascii.";
   exit();
   }

// db で認証確認
if(0 > ninsyou_out($namae, $pass)){
   echo "passwd and user name err.";
   echo "<META http-equiv=refresh content='0; url=./index.html' >";
   exit();
   }
// db のタイムスタンプセット
if(0 > ninsyou_in($namae, $pass)){
   echo "db time set err.";
   echo "<META http-equiv=refresh content='0; url=./index.html' >";
   exit();
   }


// 強制アンセット
unset($_SESSION['g_namae']);
unset($_SESSION['g_pass']);

// データセット
$_SESSION['g_namae']=$namae;
$_SESSION['g_pass']=$pass;


// ジャンプ
echo "<META http-equiv=refresh content='0; url=./index.php' >";

echo "</body>";
echo "</html>";

?>



