3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(session_start()) { ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Registration</title> <link rel="stylesheet" href="style.css"/> </head> <body> <?php $_REQUEST = array('username' => 'io', 'check' => 'Register'); // When form submitted, insert values into the database. if (isset($_REQUEST['check'])) { //require('db.php'); // removes backslashes /*$username = stripslashes($_REQUEST['username']); //escapes special characters in a string $username = mysqli_real_escape_string($con, $username); $email = stripslashes($_REQUEST['email']); $email = mysqli_real_escape_string($con, $email); $password = stripslashes($_REQUEST['password']); $password = mysqli_real_escape_string($con, $password); $create_datetime = date("Y-m-d H:i:s"); $query = "INSERT into `users` (username, password, email, create_datetime) VALUES ('$username', '" . md5($password) . "', '$email', '$create_datetime')"; $result = mysqli_query($con, $query);*/ $result = true; if ($result) { ?> <div class="form"> <h3>You are registered successfully.</h3><br/> <p class="link">Click here to <a href="login.php">Login</a></p> </div> <?php } else { ?> <div class="form"> <h3>Required fields are missing.</h3><br/> <p class="link">Click here to <a href="registration.php">registration</a> again.</p> </div> <?php } } else { ?> <form class="form" action="" method="post"> <h1 class="login-title">Registration</h1> <input type="text" class="login-input" name="username" placeholder="Username" required /> <input type="text" class="login-input" name="email" placeholder="Email Adress"> <input type="password" class="login-input" name="password" placeholder="Password"> <input type="submit" name="check" value="Register" class="login-button"> <p class="link">Already have an account? <a href="login.php">Login here</a></p> </form> <?php } } else { echo 'Session not work'; } ?> </body> </html>
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Registration</title> <link rel="stylesheet" href="style.css"/> </head> <body> <div class="form"> <h3>You are registered successfully.</h3><br/> <p class="link">Click here to <a href="login.php">Login</a></p> </div> </body> </html>

preferences:
78.53 ms | 407 KiB | 5 Q