5分位で書いてみた。セキュリティもログイン状態の維持も気にしてない。ただ概念上のサンプルとして書いておく。(ヽ´ω`)
■登録フォーム
<?php if($_SERVER['REQUEST_METHOD'] ==='POST'){ $redis = new Redis(); $redis->connect('localhost', 6379); if($redis->setnx(trim($_POST['name']), md5(trim($_POST['pass'])))){ $msg = 'registered!'; } else{ $msg = 'not registered!'; } } else{ $msg = 'Input!'; } ?>
<!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="Content-Type" content="text/html; charset=utf-8" /> <title>登録フォーム</title> </head> <body> <form action="./register.php" method="post"> <p><?php print($msg); ?></p> <dl> <dt>name</dt> <dd><input type="text" name="name" /></dd> <dt>pass</dt> <dd><input type="password" name="pass" /></dd> </dl> <p><input type="submit" name="submit" value="submit" /></p> </form> </body> </html>
■ログインフォーム
<?php if($_SERVER['REQUEST_METHOD'] ==='POST'){ $redis = new Redis(); $redis->connect('localhost', 6379); if($value = $redis->get(trim($_POST['name']))){ if($value === md5(trim($_POST['pass']))){ $msg = 'Login!'; } else{ $msg = 'Wrong!(pass)'; } } else{ $msg = 'Wrong!(name)'; } } else{ $msg = 'Input!'; } ?>
<!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="Content-Type" content="text/html; charset=utf-8" /> <title>ログインフォーム</title> </head> <body> <form action="./login.php" method="post"> <p><?php print($msg); ?></p> <dl> <dt>name</dt> <dd><input type="text" name="name" /></dd> <dt>pass</dt> <dd><input type="password" name="pass" /></dd> </dl> <p><input type="submit" name="login" value="login" /></p> </form> </body> </html>
すごく色々考えるとGAEが最強な気がする。