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> <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=\"Shift_JIS\"> <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 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<html> <head> <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=\"Shift_JIS\"> <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>
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
Warning: session_start(): Cannot send session cookie - headers already sent in /in/EXZmN on line 3 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/EXZmN:3) in /in/EXZmN on line 3 <html> <head> <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=\"Shift_JIS\"> <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>
Output for 4.3.0 - 4.3.1
Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cookie - headers already sent in /in/EXZmN on line 3 Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cache limiter - headers already sent (output started at /in/EXZmN:3) in /in/EXZmN on line 3 <html> <head> <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=\"Shift_JIS\"> <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>

preferences:
249.43 ms | 403 KiB | 369 Q