Sahitya-K

sale

Apr 1st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.61 KB | None | 0 0
  1. <?php
  2.  session_start();error_reporting(0);
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7.     <title>RUS GOLD Internal Sale</title>
  8.       <link rel="icon" href="favicon.ico">
  9.       <style>
  10.         .logo {float: left;} .nav {float: right; margin: 30px; margin-right: 45px;}
  11. .nav a {font-size: 25px;text-decoration:none;color: #000; font-family: Lucida Sans Unicode; font-weight: normal;}  .nav a:hover {opacity:.5;}
  12. .sign { width: 40%; }
  13.  h1 {margin-left:170px;font-family: arial; font-size: 35px; color: #5E0000;}
  14. .sign input { float: right; padding: 15px; border: none;border-bottom: 1px solid #ccc; width: 60%; margin-right: 40px;}
  15.  input[type="submit"] {background-color:#5E0000;color:white;padding:14px 20px;margin:8px 0;border:0;cursor:pointer;width:35%;opacity:.9;}
  16.  .history {height: auto; width: 50%;float: right; margin-top: -370px;}
  17.  .history h2 {text-align:center;font-family: arial; font-size: 35px; color: #5E0000;}
  18.  .start {height: 400px; overflow-y: auto; }
  19.  ::-webkit-scrollbar {width: 10px;}
  20. ::-webkit-scrollbar-track {background: #f1f1f1; }
  21. ::-webkit-scrollbar-thumb {background: #888; }
  22. ::-webkit-scrollbar-thumb:hover {background: #555; }
  23.       </style>
  24. </head>
  25. <body>
  26.       <div class="logo">
  27.   <img style="height: 80px;" src="rus_logo.png">
  28.   <p style="margin-top: -15px; margin-left: 60px; opacity: 0.7;">beta</p>
  29. </div>
  30. <div class="nav"><a href="index.php">Claim RUS GOLD</a></div><br><br><br><br><br><br><br><br>
  31. <h1>Transfer RUS GOLD</h1><br><br>
  32. <div class="sign">
  33.     <form method="POST">
  34.     <input type="text" name="tousername" placeholder="Enter Receiver Username...."><br><br><br><br><br>
  35.     <input type="number" name="toamount" step=".01" placeholder="Enter Amount..."><br><br><br><br><br>
  36.     <input type="submit" name="submit" value="Transfer RUS GOLD"><br><br>
  37.     <?php
  38. $servername = "localhost";
  39. $username = "root";
  40. $password = "";
  41. $dbname = "users";
  42.  
  43. if (isset($_POST['submit'])) {
  44. $conn = new mysqli($servername, $username, $password, $dbname);
  45. $user =  $_SESSION['username'];
  46. $hi = mysqli_query($conn, "SELECT sum(points) from points WHERE username='$user'");
  47. $ji = mysqli_fetch_array($hi);
  48.  
  49. $user =  $_SESSION['username'];
  50. $username = $_POST['tousername'];
  51. $amount = $_POST['toamount'];
  52.  
  53. if ($ji[0] < $amount) {
  54.     echo "<script> alert('Insufficent Balances'); </script>";
  55.     }  else {
  56.       $transfer = $ji[0] - $amount;
  57.           $sql = "DELETE FROM points WHERE username = '$user'";
  58.           $conn->query($sql);
  59.          $sq = "INSERT INTO points (username, points) VALUES ('$user', '$transfer')";
  60.           $conn->query($sq);
  61.           $s = "INSERT INTO points (username, points) VALUES ('$username', '$amount')";
  62.  
  63.           if ($conn->query($s) === TRUE) {
  64.             $tim = gmdate("l jS F Y h:i:s A ") . "( GMT )";
  65.             $sa = "INSERT INTO transfer (from_u, amount, to_u, tim) VALUES ('$user', '$amount', '$username', '$tim')";
  66.           $conn->query($sa);
  67.                echo "<script>alert('Successfully Transfered " .$amount. " to " .$username. "');
  68.               window.location.href='sale.php'; </script>";
  69.           } else {
  70.             echo "There is an Error, Please Try Again Later."; //$conn->error;
  71.           }
  72.     }
  73.  
  74.  
  75. }
  76.  
  77.     ?>
  78. </form>
  79. </div>
  80. <div class="history">
  81.     <h2>Last Transactions</h2>
  82.     <div class="start">
  83.     <?php
  84.            $servername = "localhost";
  85. $username = "root";
  86. $password = "";
  87. $dbname = "users";
  88.  
  89. // Create connection
  90. $conn = new mysqli($servername, $username, $password, $dbname);
  91.    $sql = "SELECT * FROM transfer ORDER BY id DESC";
  92.                  $result = $conn->query($sql);
  93.                if (!$result){
  94.                   die('There is an Error. Please Try Again. ');//.mysqli_error($conn));
  95.                 } else {
  96.                     echo "<br>";
  97.                     echo "<table style='width:100%;'>";
  98.                     echo "<tr>"; echo "<th>From</th>"; echo "<th>Amount</th>"; echo "<th>To</th>";
  99.                      echo "<th>Time</th>";
  100.                     echo "<tr>";
  101.                 while($row = mysqli_fetch_assoc($result)) {
  102.                     echo "<tr>";
  103.                     echo "<td style='text-align: center; padding:15px; border-bottom:1px solid #000;'>"; echo $row["from_u"]; echo "</td>";
  104.                     echo "<td style='text-align: center; border-bottom:1px solid #000;'>"; echo $row["amount"]; echo "</td>";
  105.                     echo "<td style='text-align: center; border-bottom:1px solid #000;'>"; echo $row["to_u"]; echo "</td>";
  106.                     echo "<td style='text-align: center; border-bottom:1px solid #000;'>"; echo $row["tim"]; echo "</td>";
  107.                     echo "</tr>";
  108.  
  109.                 }
  110. }
  111.  
  112.     ?>
  113.     </div>
  114. </div>
  115. </body>
  116. </html>
Add Comment
Please, Sign In to add comment