Guest User

wtf

a guest
Mar 3rd, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <HTML>
  2.  
  3. <form method="POST">
  4. <input type="text" name="weight" value="">
  5. <input type="submit" value="Submit">
  6. </form>
  7.  
  8. <?php
  9. require('connect.php');
  10.  
  11. // Create connection
  12. $conn = new mysqli($servername, $username, $password, $dbname);
  13. // Check connection
  14. if ($conn->connect_error) {
  15.     die("Connection failed: " . $conn->connect_error);
  16. }
  17.  
  18. //declare weight var
  19.  
  20.  
  21. $weight = $_POST['weight'];
  22.  
  23. if(!isset($weight)){
  24.  
  25.   echo "Please enter your current weight";
  26. }
  27. else {
  28.  
  29.  
  30.  
  31. $sql = "INSERT INTO weighttracker (id, date, weight)
  32. VALUES (0, CURDATE(), $weight)";
  33.  
  34. if ($conn->query($sql) === TRUE) {
  35.     echo "New record created successfully";
  36. } else {
  37.     echo "Error: " . $sql . "<br>" . $conn->error;
  38. }
  39.  
  40. }
  41.  
  42. $conn->close();
  43.  
  44.  
  45. ?>
  46. </htML>
Advertisement
Add Comment
Please, Sign In to add comment