Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. # Dati del database [Mysql]
  4. $db = [
  5.  
  6. 'status' => true,
  7.  
  8. 'user' => "USER",
  9.  
  10. 'password' => "Password dell'utente",
  11.  
  12. 'host' => "localhost",
  13.  
  14. 'db_name' => "DB assegnato all'user"
  15. ];
  16.  
  17. if ($db['status']) {
  18. try {
  19.     $PDO = new PDO("mysql:host=".$db['host'].";dbname=".$db['db_name'], $db['user'], $db['password']);
  20.     }
  21. catch(PDOException $e) {
  22.         echo "Connection failed: " . $e->getMessage();
  23.     }
  24.  
  25.  
  26. $fetch = $PDO->prepare("SELECT * FROM users WHERE user_id = ?");
  27. $fetch->execute([$Bot->user_id]);
  28. $f = $fetch->fetch(\PDO::FETCH_ASSOC);
  29.  
  30.   if($Bot->chat_id > 0 or $Bot->chat_id == $group) {
  31.     if ($f['user_id'] != $Bot->user_id) {
  32.        if (!$Bot->cognome) {
  33.           $last_name = "";
  34.      } else {
  35.        $last_name = $Bot->cognome;
  36.      }
  37.      if (!$Bot->username) {
  38.           $username = "";
  39.      } else {
  40.        $username = $Bot->username;
  41.      }
  42.     $insert = $PDO->prepare("INSERT INTO users (user_id, first_name, last_name, username, status) VALUES (?,?,?,?,?)");
  43.     $insert->execute([$Bot->user_id, $Bot->nome, $last_name, $username, '0']);
  44.    }
  45.  }
  46. }
  47.  
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement