Check - 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 Check.php

  1. <?php
  2.         $username = filter_var(trim($_POST['username']),
  3.         FILTER_SANITIZE_STRING);       
  4.         $password = filter_var(trim($_POST['password']),
  5.         FILTER_SANITIZE_STRING);       
  6.  
  7.         $password = md5($password.'ghjsfkld2345');
  8.  
  9.         $mysql = new mysqli("z111349.hostru12.fornex.host", "z111349_dbuser", "5TAaupiN>j4zPH$X", "z111349_auth");
  10.  
  11.         $result = $mysql->query("SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'");
  12.  
  13.         $user = $result->fetch_assoc();
  14.         if (count($user) == 0) {
  15.                 echo 'Такой пользователь не найден';
  16.                 exit();
  17.         }
  18.  
  19.         setcookie('user', $user['name'], time() + 3600, '/');
  20.  
  21.         $mysql->close();
  22.  
  23.         header('Location: /');
  24.  
  25. ?>
  26.  
File Description
  • Check
  • PHP Code
  • 02 Sep-2022
  • 668 Bytes
You can Share it: