アットウィキロゴ

PHP

<html>
<head>
<title>login...</title>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
</head>
<body>

<?php

if( !$link = mysql_connect("192.168.54.112", usr)){
       print "connect error<br>";
       exit;
}
if( !mysql_select_db("hyojun", $link) ){
       print "db change error<br>";
       exit;
}

$id=$_POST['id'];
$pass=$_POST['pass'];
$table="";
$codename="";
$idname="";
$passname="";
$url="";

print "id :".$id."<br>";
print "pass:".$pass."<br>";

if( !strncmp($id, "te", 2 )){ print "teacher<br>";
       $table="T_teacher";
       $codename="tecode";
       $idname="teid";
       $passname="tepas";
       $url="test.php?code=";

}else if( !strncmp($id, "st", 2 )){
       print "student<br>";
       $table="T_student";
       $codename="stcode";
       $idname="stid";
       $passname="stpas";

}else if( !strncmp($id, "of", 2 )){
       print "officer<br>";
       $table="T_officer";
       $codename="ofcode";
       $idname="ofid";
       $passname="ofpas";

}else if( !strncmp($id, "ad", 2 )){
       print "admin<br>";
       $table="T_admin";
       $codename="adcode";
       $idname="adid";
       $passname="adpas";

}else{
       print "<br>そのIDはどこにも属していません><<br>再度お確かめ下さい<br>";
       exit;
}


if( $table!=""){

       $sql = "SELECT ".$codename." FROM ".$table." WHERE ".$idname."='".$id."'";
       $sql = $sql." and ".$passname."='".$pass."';";

       print "sql:".$sql."<br>";

       $res = mysql_query($sql,$link);
       $num=mysql_num_rows($res);
       if($num==0){
               print "IDかpassが間違っています";
       }else{
               $row = mysql_fetch_array($res);
               $code = $row[$codename];

               print("現在ページを移動中です。<br>");

               print("<SCRIPT langage=\"JavaScript\"");
               print("<!--");
               print("location.replace(\"".$url.$code."\");");
               print("-->");
               print("</SCRIPT>");

                   print("いつまでも移動しない場合は<a href=\"".$url.$code."\">こちら</a><br>");
       }
}


?>


</body>
</html> print "code:".$code."<br>";
最終更新:2007年02月01日 15:57