3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); $error_message = ""; // ログインボタンが押されたかを判定 // 初めてのアクセスでは認証は行わずエラーメッセージは表示しないように if (isset($_POST["login"])) { // ID・パスの入力チェック(未実装、現状はIDに半角数字以外を入れるとおかしくなる) // DB $url = "localhost"; $user = "root"; $pass = ""; $db = "test"; // MySQLへ接続する $link = mysql_connect($url,$user,$pass) or die("MySQLへの接続に失敗しました。"); // データベースを選択する $sdb = mysql_select_db($db,$link) or die("データベースの選択に失敗しました。"); // クエリを送信する ID・パス照会 $sql = "select * from user "; $sql.= "where user_id= " . $_REQUEST["user_id"] ; $result = mysql_query($sql, $link) or die("クエリの送信に失敗しました。<br/>SQL:".$sql); $row = mysql_fetch_assoc($result); // ①パスワードが一致する場合、ログイン if ($row["password"] == $_REQUEST["password"]){ // ログインが成功した証をセッションに保存 $_SESSION["user_id"] = $_REQUEST["user_id"]; $_SESSION["name"] = $row["name"]; $_SESSION["user_class"] = $row["class"]; // トップ画面へリダイレクト $login_url = "top.php"; header("Location: {$login_url}"); } // ②一致しない場合、エラーメッセージを格納 else{ $error_message = "ID・パスワードをお確かめください。"; } // MySQLへの接続を閉じる mysql_close($link) or die("MySQL切断に失敗しました。"); // ボタン判定終わり } ?> <html> <head> <title>ログイン画面</title> </head> <body> <center> <br> <br> <font size="2" >日程調整ツール「作成さん」</font><br> <br> <font size="5" >ログイン</font><br> <br> <br> <?php if ($error_message) { print '<font color="red">'.$error_message.'</font>'; } ?> <!-- できたらフォーム位置整えたい --> <form action="login.php" method="POST">      ID:<input type="text" name="user_id" value="" /><br /> パスワード:<input type="password" name="password" value"" /><br /> <input type="submit" name="login" value="送信" /> </form> </center> </body> </html>
Output for git.master, git.master_jit, rfc.property-hooks
<html> <head> <title>ログイン画面</title> </head> <body> <center> <br> <br> <font size="2" >日程調整ツール「作成さん」</font><br> <br> <font size="5" >ログイン</font><br> <br> <br> <!-- できたらフォーム位置整えたい --> <form action="login.php" method="POST">      ID:<input type="text" name="user_id" value="" /><br /> パスワード:<input type="password" name="password" value"" /><br /> <input type="submit" name="login" value="送信" /> </form> </center> </body> </html>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.33 ms | 402 KiB | 8 Q