Advertisement
TsungUK

AGK-PHP Page

Jan 31st, 2023
1,335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | Software | 0 0
  1. <?php
  2.  
  3. CONST DEFAULT_CREDITS=30;
  4. $servername =  ""; // Server Name
  5. $dbname = "";     // Database Name
  6. $username = "";   // Database Username
  7. $password = "";   // Database Password
  8. $pid = $_REQUEST['pid'];
  9.                            
  10.     try {
  11.     $conn = new PDO("mysql:host=$servername;dbname=".$dbname, $username, $password);
  12.     // set the PDO error mode to exception
  13.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  14.  //   echo "Connected successfully";
  15.         }
  16.  
  17. catch(PDOException $e)
  18.     {
  19.  //   echo "x Connection failed: " . $e->getMessage();
  20.     die();
  21.     }
  22.     $sql = "select * from `tblusers`  where UniqueRef = '".$pid."' Limit 1;";
  23.   // echo '<br>'.$sql;
  24.     $stmt = $conn->prepare($sql);
  25.     $stmt->execute();
  26.     $row=$stmt->fetch();
  27.     $Credits= $row['Credits'];    
  28.  
  29. if ($Credits == "" ) {
  30.     $sql = "INSERT INTO `tblusers` (`UserID`, `UniqueRef`, `Credits`, `CreateDate`, `LastSeen`) VALUES (NULL, '".$pid."', '30', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);";
  31.     $stmt = $conn->prepare($sql);
  32.     $stmt->execute();
  33.     $Credits=DEFAULT_CREDITS;
  34. }
  35.  
  36. echo $Credits;
  37.  
  38. ?>
Tags: AGK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement