Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.64 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Init variables
  5. */
  6.  
  7. $servername = "104.168.99.210";
  8. $username = "matejr";
  9. $password = "matejremote";
  10. $database = "sharedDB";
  11. $tablename = "registry"; //This is the table in the db u wanna set it ot retard
  12.  
  13. if (isset($_POST['submit']))
  14. {
  15. /*
  16. Create connection to db
  17. */
  18. $con = mysqli_connect($servername,$username,$password,$database);
  19.  
  20.  
  21. // Check connection if error tell the retarded user
  22. if (mysqli_connect_errno())
  23.   {
  24.   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  25.   }
  26.  
  27. $val1 =  $_POST['a'];;
  28. /*
  29. $val2 =  $_POST['b'];;
  30. $val3 =  $_POST['c'];;
  31. $val4 =  $_POST['d'];;
  32. */
  33. /*
  34.  Creates the SQL statement
  35. ---------------------
  36. Change a b c d to the name of the table thing you got like
  37. ID , lastname or whatever the fuck u got
  38. */
  39.  
  40. #$sql = "INSERT INTO " . $tablename . " (a , b , c , d) VALUES ('" . $val1 . "' , '" . $val2 . "' , '" . $val3 . "' , '" . $val4 ."')";
  41. #$sql = "UPDATE" . $tablename . "SET value='" . $val1 . "' WHERE regID=1";
  42. $sql = "UPDATE registry SET value='" . $val1 . "' WHERE RegID=1";
  43. #$sql = "UPDATE registry SET value="' . $val1 . '" WHERE RegID=1";
  44. #$sql = "UPDATE " . $tablename ." SET value=" (a) " WHERE regID = '1'";
  45. #$sql = "INSERT INTO " . $tablename . " (a , b , c , d) VALUES ('" . $val1 . "' , '" . $val2 . "' , '" . $val3 . "' , '" . $val4 ."')";
  46. if($con->query($sql) === TRUE )
  47. {
  48.   //Get everything from our table we set before
  49.   $sql2 = "SELECT value FROM registry WHERE regID=1";
  50. #    $sql2 = "SELECT * FROM `registry";
  51. $result = $con->query($sql2);
  52.  
  53.   if($result)
  54.   {
  55.     while($row = $result->fetch_assoc())
  56.     {
  57. #      $printstuff = "A is: " . $row["a"]. "<br>";
  58.      $printstuff = "A is: " . $row["value"]. "<br>";
  59. #       $printstuff = "A is: " . $row["a"]. " - B is: " . $row["b"] . " C is  " . $row["c"] . "D is " . $row["d"] . "<br>";
  60.       #$printstuff = "Value on remote server is" '" . $sql2. "';
  61.     echo $printstuff;
  62.     }
  63.     $result->free();
  64.   }
  65.   else
  66.   {
  67.      $printstuff = "0 results";
  68.      echo $printstuff;
  69.   }
  70. }
  71. else
  72. {
  73.   echo "Error: "  . $sql . "<br>" . $con->error;
  74. }
  75.  
  76.  
  77. //Close the database
  78. $con->close();
  79.  
  80. }
  81.  
  82. // PHP Sucks
  83. ?>
  84.  
  85. <!DOCTYPE html>
  86. <html lang="en">
  87.   <head>
  88.     <meta charset="utf-8">
  89.     <title>title</title>
  90.     <link rel="stylesheet" href="style.css">
  91.     <script src="script.js"></script>
  92.   </head>
  93.   <body>
  94.                 <form action="" method="post">
  95.                         A: <input type="text" name="a"><br>
  96.                         <input type="submit" name="submit">
  97.                 </form>
  98. <br>opening from debian7.maros.online
  99. <br>database from server.maros.online
  100.   </body>
  101. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement