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> <? } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 74
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 62
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/6p59E
function name:  (null)
number of ops:  80
compiled vars:  !0 = $sql, !1 = $results, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INCLUDE_OR_EVAL                                          'config.php', INCLUDE
   48     1        FETCH_IS                                         ~4      '_POST'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      ~4, 'Submit'
          3      > JMPZ_EX                                          ~5      ~5, ->8
          4    >   FETCH_R                      global              ~6      '_POST'
          5        FETCH_DIM_R                                      ~7      ~6, 'Submit'
          6        IS_EQUAL                                         ~8      ~7, 'Register'
          7        BOOL                                             ~5      ~8
          8    > > JMPZ                                                     ~5, ->74
   52     9    >   FETCH_R                      global              ~9      '_POST'
         10        FETCH_DIM_R                                      ~10     ~9, 'username'
         11        CONCAT                                           ~11     'select+Name%2CEmail+from+accounts+where+Name%3D%27', ~10
         12        CONCAT                                           ~12     ~11, '%27+or+Email%3D%27'
         13        FETCH_R                      global              ~13     '_POST'
         14        FETCH_DIM_R                                      ~14     ~13, 'email'
         15        CONCAT                                           ~15     ~12, ~14
         16        CONCAT                                           ~16     ~15, '%27'
         17        ASSIGN                                                   !0, ~16
   53    18        INIT_FCALL_BY_NAME                                       'mysql_query'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $18     
         21        ASSIGN                                           ~19     !1, $18
         22      > JMPNZ_EX                                         ~19     ~19, ->27
         23    >   INIT_FCALL_BY_NAME                                       'mysql_error'
         24        DO_FCALL                                      0  $20     
         25      > EXIT                                                     $20
         26*       BOOL                                             ~19     <true>
   54    27    >   INIT_FCALL_BY_NAME                                       'mysql_num_rows'
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0  $21     
         30        IS_SMALLER                                               0, $21
         31      > JMPZ                                                     ~22, ->62
   56    32    >   INIT_FCALL_BY_NAME                                       'mysql_fetch_row'
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0  $23     
         35        ASSIGN                                                   !2, $23
   58    36        FETCH_R                      global              ~25     '_POST'
         37        FETCH_DIM_R                                      ~26     ~25, 'username'
         38        FETCH_DIM_R                                      ~27     !2, 0
         39        IS_EQUAL                                                 ~26, ~27
         40      > JMPZ                                                     ~28, ->43
   60    41    >   ECHO                                                     'Username+already+taken%21'
         42      > JMP                                                      ->61
   63    43    >   FETCH_R                      global              ~29     '_POST'
         44        FETCH_DIM_R                                      ~30     ~29, 'email'
         45        FETCH_DIM_R                                      ~31     !2, 1
         46        IS_EQUAL                                                 ~30, ~31
         47      > JMPZ                                                     ~32, ->50
   65    48    >   ECHO                                                     'The+e-mail+already+used+for+registration%21'
         49      > JMP                                                      ->61
   70    50    >   INIT_FCALL                                               'register'
         51        FETCH_R                      global              ~33     '_POST'
         52        FETCH_DIM_R                                      ~34     ~33, 'username'
         53        SEND_VAL                                                 ~34
         54        FETCH_R                      global              ~35     '_POST'
         55        FETCH_DIM_R                                      ~36     ~35, 'password'
         56        SEND_VAL                                                 ~36
         57        FETCH_R                      global              ~37     '_POST'
         58        FETCH_DIM_R                                      ~38     ~37, 'email'
         59        SEND_VAL                                                 ~38
         60        DO_FCALL                                      0          
         61    > > JMP                                                      ->73
   76    62    >   INIT_FCALL                                               'register'
         63        FETCH_R                      global              ~40     '_POST'
         64        FETCH_DIM_R                                      ~41     ~40, 'username'
         65        SEND_VAL                                                 ~41
         66        FETCH_R                      global              ~42     '_POST'
         67        FETCH_DIM_R                                      ~43     ~42, 'password'
         68        SEND_VAL                                                 ~43
         69        FETCH_R                      global              ~44     '_POST'
         70        FETCH_DIM_R                                      ~45     ~44, 'email'
         71        SEND_VAL                                                 ~45
         72        DO_FCALL                                      0          
         73    > > JMP                                                      ->79
   80    74    >   ECHO                                                     '%0A%3C%21----+the+form+to+take+input+----%21%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A%3Cform+action%3D%22'
   84    75        FETCH_R                      global              ~47     '_SERVER'
         76        FETCH_DIM_R                                      ~48     ~47, 'PHP_SELF'
         77        FREE                                                     ~48
         78        ECHO                                                     '%22+method%3D%22post%22%3E%0A%3Cinput+type%3D%22text%22+value%3D%22username%22+align%3D%22LEFT%22+name%3D%22username%22+%2F%3E%0A%3Cbr%3E%0A%3Cinput+type%3D%22password%22+value%3D%22password%22+name%3D%22password%22+%2F%3E%0A%3Cbr%3E%0A%3Cinput+type%3D%22text%22+value%3D%22email%22+name%3D%22email%22+%2F%3E%0A%3Cbr%3E%0A%3Cinput+type%3D%22submit%22+value%3D%22Register%22+name%3D%22Submit%22+%2F%3E%0A%3C%2Fform%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A'
   98    79    > > RETURN                                                   1

Function register:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 47) Position 1 = 52, Position 2 = 56
Branch analysis from position: 52
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/6p59E
function name:  register
number of ops:  66
compiled vars:  !0 = $username, !1 = $password, !2 = $email, !3 = $query, !4 = $results, !5 = $row, !6 = $user_id, !7 = $enc_password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    8     3        ASSIGN                                                   !3, 'select+max%28Id%29+as+total+from+accounts'
    9     4        INIT_FCALL_BY_NAME                                       'mysql_query'
          5        SEND_VAR_EX                                              !3
          6        DO_FCALL                                      0  $9      
          7        ASSIGN                                           ~10     !4, $9
          8      > JMPNZ_EX                                         ~10     ~10, ->13
          9    >   INIT_FCALL_BY_NAME                                       'mysql_error'
         10        DO_FCALL                                      0  $11     
         11      > EXIT                                                     $11
         12*       BOOL                                             ~10     <true>
   10    13    > > JMPZ                                                     !4, ->21
   11    14    >   INIT_FCALL_BY_NAME                                       'mysql_fetch_row'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !5, $12
   12    18        FETCH_DIM_RW                                     $14     !5, 0
         19        PRE_INC                                          ~15     $14
         20        ASSIGN                                                   !6, ~15
   16    21    >   INIT_FCALL                                               'md5'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !7, $17
   17    25        INIT_FCALL_BY_NAME                                       'mysql_free_result'
         26        SEND_VAR_EX                                              !4
         27        DO_FCALL                                      0          
   20    28        ASSIGN                                                   !3, 'insert+into+accounts%28Id%2CName%2CPassword%2CEmail%2CAccessLevel%2CMembership%2CLastOnlineUtc%2CCoins%29'
   21    29        CONCAT                                           ~21     !3, 'values%28%27'
         30        CONCAT                                           ~22     ~21, !6
         31        CONCAT                                           ~23     ~22, '%27%2C%27'
         32        CONCAT                                           ~24     ~23, !0
         33        CONCAT                                           ~25     ~24, '%27%2C%27'
         34        CONCAT                                           ~26     ~25, !7
         35        CONCAT                                           ~27     ~26, '%27%2C%27'
         36        CONCAT                                           ~28     ~27, !2
         37        CONCAT                                           ~29     ~28, '%27%2C%27'
         38        CONCAT                                           ~30     ~29, '0'
         39        CONCAT                                           ~31     ~30, '%27%2C%27'
         40        CONCAT                                           ~32     ~31, '0'
         41        CONCAT                                           ~33     ~32, '%27%2C%27'
         42        CONCAT                                           ~34     ~33, '0'
         43        CONCAT                                           ~35     ~34, '%27%2C%27'
         44        CONCAT                                           ~36     ~35, '0'
         45        CONCAT                                           ~37     ~36, '%27%29'
         46        ASSIGN                                                   !3, ~37
   23    47        INIT_FCALL_BY_NAME                                       'mysql_query'
         48        SEND_VAR_EX                                              !3
         49        DO_FCALL                                      0  $39     
         50        ASSIGN                                           ~40     !4, $39
         51      > JMPNZ_EX                                         ~40     ~40, ->56
         52    >   INIT_FCALL_BY_NAME                                       'mysql_error'
         53        DO_FCALL                                      0  $41     
         54      > EXIT                                                     $41
         55*       BOOL                                             ~40     <true>
   25    56    > > JMPZ                                                     !4, ->63
   27    57    >   CONCAT                                           ~42     'Welcome+', !0
         58        CONCAT                                           ~43     ~42, '%21'
         59        ECHO                                                     ~43
   28    60        ECHO                                                     '+...+Account+successfully+registered%21'
   29    61      > RETURN                                                   1
         62*       JMP                                                      ->65
   33    63    >   ECHO                                                     'Registration+failed'
   34    64      > RETURN                                                   0
   36    65*     > RETURN                                                   null

End of function register

Function activate_user:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/6p59E
function name:  activate_user
number of ops:  16
compiled vars:  !0 = $user_id, !1 = $query, !2 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        CONCAT                                           ~3      'update+accounts+set+Membership%3D1+where+Id%3D', !0
          2        ASSIGN                                                   !1, ~3
   40     3        INIT_FCALL_BY_NAME                                       'mysql_query'
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                           ~6      !2, $5
          7      > JMPNZ_EX                                         ~6      ~6, ->12
          8    >   INIT_FCALL_BY_NAME                                       'mysql_error'
          9        DO_FCALL                                      0  $7      
         10      > EXIT                                                     $7
         11*       BOOL                                             ~6      <true>
   41    12    >   BOOL_NOT                                         ~8      !2
         13      > JMPZ                                                     ~8, ->15
   43    14    >   ECHO                                                     'The+account+has+been+activated%21'
   45    15    > > RETURN                                                   null

End of function activate_user

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.84 ms | 1415 KiB | 17 Q