3v4l.org

run code in 300+ PHP versions simultaneously
<?php include "config.php"; //the database configuration file. Update this to connect to your databse //function to regiter function register($username,$password,$email) { //find the next userid $query="select max(Id) as total from accounts"; $results=mysql_query($query) or die(mysql_error()); if($results){ $row=mysql_fetch_row($results);//store the result in $row array $user_id=++$row['0'];//increment the currnet user_id by 1 } //encrypt the password using md5 $enc_password=md5($password); mysql_free_result($results);//free the result //insert new registration details to database $query="insert into accounts(Id,Name,Password,Email,AccessLevel,Membership,LastOnlineUtc,Coins)"; $query=$query."values('".$user_id."','".$username."','".$enc_password."','".$email."','"."0"."','"."0"."','"."0"."','"."0"."')"; $results=mysql_query($query) or die(mysql_error()); if($results) { echo 'Welcome '.$username.'!'; echo " ... Account successfully registered!"; return 1; } else { echo "Registration failed"; return 0; } } //function to activate the user. Give the user id as the parameter. function activate_user($user_id){ $query="update accounts set Membership=1 where Id=".$user_id; $results=mysql_query($query) or die(mysql_error()); if(!$results) { echo "The account has been activated!"; } } //check if the form was submitted if((isset($_POST['Submit']) && $_POST['Submit']=="Register")) { //check whether the username and e-mail already exist or not $sql="select Name,Email from accounts where Name='".$_POST['username']."' or Email='".$_POST['email']."'"; $results=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($results)>0) { $row=mysql_fetch_row($results); //check if username exists if($_POST['username']==$row['0']) { echo "Username already taken!"; } //check if e-mail exists elseif($_POST['email']==$row['1']) { echo "The e-mail already used for registration!"; } else { //if username and e-mail not used, register the new user to database register($_POST['username'],$_POST['password'],$_POST['email']); } } else { //register new user to access register($_POST['username'],$_POST['password'],$_POST['email']); } }else{ ?> <!---- the form to take input ----!> <html> <body> <form action="<? $_SERVER['PHP_SELF'] ?>" method="post"> <input type="text" value="username" align="LEFT" name="username" /> <br> <input type="password" value="password" name="password" /> <br> <input type="text" value="email" name="email" /> <br> <input type="submit" value="Register" name="Submit" /> </form> </body> </html> <? } ?>
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Parse error: Unclosed '{' on line 78 in /in/6p59E on line 98
Process exited with code 255.
Output for 8.0.13
Warning: include(config.php): Failed to open stream: No such file or directory in /in/6p59E on line 2 Warning: include(): Failed opening 'config.php' for inclusion (include_path='.:') in /in/6p59E on line 2 <!---- the form to take input ----!> <html> <body> <form action="" method="post"> <input type="text" value="username" align="LEFT" name="username" /> <br> <input type="password" value="password" name="password" /> <br> <input type="text" value="email" name="email" /> <br> <input type="submit" value="Register" name="Submit" /> </form> </body> </html>
Output for 5.4.0 - 5.4.45, 7.3.32 - 7.3.33, 7.4.26, 7.4.33
Warning: include(config.php): failed to open stream: No such file or directory in /in/6p59E on line 2 Warning: include(): Failed opening 'config.php' for inclusion (include_path='.:') in /in/6p59E on line 2 <!---- the form to take input ----!> <html> <body> <form action="" method="post"> <input type="text" value="username" align="LEFT" name="username" /> <br> <input type="password" value="password" name="password" /> <br> <input type="text" value="email" name="email" /> <br> <input type="submit" value="Register" name="Submit" /> </form> </body> </html>
Output for 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.32
Parse error: syntax error, unexpected end of file in /in/6p59E on line 98
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected $end in /in/6p59E on line 98
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected $ in /in/6p59E on line 98
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/6p59E on line 98
Process exited with code 255.

preferences:
327.63 ms | 401 KiB | 460 Q