3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); $before = $_SESSION['before']; if($before == 'http://medalwars.url.ph/'){ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $username = $_POST['username']; $password = $_POST['password']; }else{ $_SESSION['foutcode'] = 'foutcode 001'; header("location: $before"); exit(); } require_once 'db_config.php'; $sql = "SELECT username, password FROM users WHERE username = '$username' AND password = '$password'"; if(!mysql_query($sql)){ $_SESSION['foutcode'] = 'foutcode 004'; header("location: $before"); exit(); } $mysqli = new mysqli($db['host'], $db['user'], $db['pass'], $db['dbname']); $result = $mysqli->query($sql); $row = $result->fetch_assoc(); if($username == htmlentities($row['username']) AND $password == htmlentities($row['password'])){ $_SESSION['logged_in'] = 'true'; $_SESSION['gebruiker'] = $username; $_SESSION['foutcode'] = 'foutcode 011'; header("location: /ingame"); exit(); }else{ $_SESSION['foutcode'] = 'foutcode 008'; header("location: $before"); exit(); } }elseif($before == 'http://medalwars.url.ph/create_account/'){ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $email = $_POST['e-mail']; }else{ $_SESSION['foutcode'] = 'foutcode 001'; header("location: $before"); exit(); } require_once 'db_config.php'; $ip = $_SERVER['REMOTE_ADDR']; $sql = "INSERT INTO users (username, password, ip, email) VALUES (\"$username\",\"$password\",\"$ip\",\"$email\")"; if(!mysql_query($sql)){ $_SESSION['foutcode'] = 'foutcode 004'; header("location: $before"); exit(); }else{ $mysqli = new mysqli($db['host'], $db['user'], $db['pass'], $db['dbname']); $query = mysql_query($sql, $mysqli); $_SESSION['logged_in'] = 'create'; $_SESSION['gebruiker'] = $username; $naam_verzender = 'MedalWars'; $email_verzender = 'noreply@medalwars.url.ph'; $onderwerp = 'Accountregistratie MedalWars'; $headers = "From: ".$naam_verzender." <".$email_verzender."> "; $bericht = " Beste $username, Hierbij ontvangt u de bevestiging voor het aanmaken van uw account. Uw inloggegevens zijn: Gebruikersnaam: $username. Wachtwoord: $password. Let op: u ontvangt deze gegevens eenmalig per e-mail. Als u uw wachtwoord vergeet zullen wij deze niet via e-mail verstrekken. Bewaar deze e-mail dus goed. Geef ook wijzigingen van uw e-mailadres tijdig aan onder instellingen op de website. Wij hopen dat u veel plezier zult hebben met het spelen van dit spel. mvg, Het MedalWars team - www.medalwars.url.ph "; mail($email, $onderwerp, $bericht, $headers); header("location: $before"); exit(); } }elseif($before == ''){ $_SESSION['foutcode'] = 'foutcode 009'; header("location: http://medalwars.url.ph/"); }else{ $_SESSION['foutcode'] = 'foutcode 010'; header("location: http://medalwars.url.ph/"); } ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Warning: Undefined array key "before" in /in/IQgF1 on line 3 Warning: Cannot modify header information - headers already sent by (output started at /in/IQgF1:3) in /in/IQgF1 on line 91
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined index: before in /in/IQgF1 on line 3 Warning: Cannot modify header information - headers already sent by (output started at /in/IQgF1:3) in /in/IQgF1 on line 91
Output for 5.2.3 - 5.2.17, 7.3.32 - 7.3.33, 7.4.26
Output for 4.4.3 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in <b>/in/IQgF1</b> on line <b>2</b><br /> <br /> <b>Warning</b>: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /in/IQgF1:2) in <b>/in/IQgF1</b> on line <b>2</b><br />
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.2
<br /> <b>Warning</b>: session_start(): Cannot send session cookie - headers already sent in <b>/in/IQgF1</b> on line <b>2</b><br /> <br /> <b>Warning</b>: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/IQgF1:2) in <b>/in/IQgF1</b> on line <b>2</b><br />
Output for 4.3.0 - 4.3.1
<br /> <b>Warning</b>: session_start() [<a href='http://www.php.net/function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in <b>/in/IQgF1</b> on line <b>2</b><br /> <br /> <b>Warning</b>: session_start() [<a href='http://www.php.net/function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /in/IQgF1:2) in <b>/in/IQgF1</b> on line <b>2</b><br />

preferences:
335.3 ms | 402 KiB | 461 Q