3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.5.0 - 5.6.28, 7.0.0 - 7.1.0
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 hhvm-3.10.0 - 3.12.0
Notice: Undefined index: before in /in/IQgF1 on line 3
Output for 5.2.3 - 5.4.45
Output for 4.4.3 - 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.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 />