12 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of 12.php

  1. <?php
  2. header("Content-type: text/html;charset=utf-8");
  3.  
  4. if (sizeof($_POST)!=0){
  5.  
  6.         $link = mysqli_connect("localhost", "megaapp_user", "megaapp_app_user_pwd", "megaapp");
  7.  
  8.         if (!$link) {
  9.                 echo "ERROR: " . mysqli_connect_error() . mysqli_connect_errno() . "<br>";
  10.                 exit;
  11.         }
  12.        
  13.         $ul = mysqli_real_escape_string ($link, $_POST['ul']);
  14.         $up = sha1($_POST['up']);
  15.        
  16.         $r = mysqli_query($link, "SELECT * from `users` where `user_login`='$ul' AND `user_password`='$up' limit 1");
  17.        
  18.         if (mysqli_num_rows($r)==1) {
  19.                 echo 'OK';
  20.         } else {
  21.                 echo 'ERROR';
  22.         }
  23.        
  24.         mysqli_close($link);
  25.        
  26. } else {
  27.         $form = file_get_contents('form.tpl');
  28.         $form = str_replace('{PAGE_URL}', $_SERVER['PHP_SELF'], $form);
  29.         echo $form;
  30. }
  31.  
  32. ?>
File Description
  • 12
  • PHP Code
  • 08 Oct-2021
  • 705 Bytes
You can Share it: