3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo "<!doctype html>\n"; $username = $_GET['username']; //wouldnt use GET for passing username and password; $password = $_GET['password']; $password = password_hash($password, PASSWORD_BCRYPT, 12); $pdo = new PDO('sqlite::memory:'); //assume we don't really want to drop our users table on every run of this script. //$pdo->exec("DROP TABLE IF EXISTS users"); //$pdo->exec("CREATE TABLE users (username VARCHAR(255), password VARCHAR(255))"); $sql = "INSERT INTO users (username,password) VALUES (:username,:password)"; $q = $conn->prepare($sql); $q->execute(array(':username'=>$username,':password'=>$password)); //this would always return a result as we've just inserted a new user with those values, so I'd totally seperate out the user //registration and login code. $statement = $pdo->query("SELECT * FROM users WHERE username = '$username' AND password = '$password'"); if (count($statement->fetchAll())) { echo "Access granted to $username!<br>\n"; } else { echo "Access denied for $username!<br>\n"; }
Output for 7.0.5 - 7.1.0
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Warning: password_hash() expects parameter 3 to be array, integer given in /in/rd2fm on line 9 Notice: Undefined variable: conn in /in/rd2fm on line 18 Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/rd2fm:18 Stack trace: #0 {main} thrown in /in/rd2fm on line 18
Process exited with code 255.
Output for 7.0.0 - 7.0.4
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Warning: password_hash() expects parameter 3 to be array, integer given in /in/rd2fm on line 9 Notice: Undefined variable: conn in /in/rd2fm on line 18 Fatal error: Uncaught Error: Call to a member function prepare() on unknown in /in/rd2fm:18 Stack trace: #0 {main} thrown in /in/rd2fm on line 18
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Catchable fatal error: Argument 3 passed to password_hash() must be an instance of array, int given in /in/rd2fm on line 9
Process exited with code 255.
Output for 5.6.7 - 5.6.28
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Warning: password_hash() expects parameter 3 to be array, integer given in /in/rd2fm on line 9 Notice: Undefined variable: conn in /in/rd2fm on line 18 Fatal error: Call to a member function prepare() on null in /in/rd2fm on line 18
Process exited with code 255.
Output for 5.5.24 - 5.5.35
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Warning: password_hash() expects parameter 3 to be array, integer given in /in/rd2fm on line 9 Notice: Undefined variable: conn in /in/rd2fm on line 18 Fatal error: Call to a member function prepare() on a non-object in /in/rd2fm on line 18
Process exited with code 255.
Output for 5.3.0 - 5.4.45
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Fatal error: Call to undefined function password_hash() in /in/rd2fm on line 9
Process exited with code 255.
Output for 5.0.0 - 5.2.17
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Fatal error: Call to undefined function password_hash() in /in/rd2fm on line 9
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Fatal error: Call to undefined function: password_hash() in /in/rd2fm on line 9
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Fatal error: Call to undefined function: password_hash() in /in/rd2fm on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<!doctype html> Notice: Undefined index: username in /in/rd2fm on line 5 Notice: Undefined index: password in /in/rd2fm on line 7 Fatal error: Call to undefined function: password_hash() in /in/rd2fm on line 9