Guest User

Untitled

a guest
Jun 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. echo '<td><form action="buy_item.php"><button>Buy</button></form></td>';
  2.  
  3. <?php
  4. session_start();
  5. $conn = mysqli_connect("localhost", "localhost", "localhost", "localhost");
  6. if ($conn->connect_error) {
  7. die("Connection failed: " . $conn->connect_error);
  8. }
  9. $sql = "SELECT price,username,amount FROM items,users WHERE username = '" .
  10. $_SESSION['username'] . "' ";
  11.  
  12. $result = $conn->query($sql);
  13. if ($result->num_rows > 0) {
  14. while($row = $result->fetch_assoc()) {
  15. if $row["amount"] >= $row["price"] {
  16. $newAmount = $row["amount"] - $row["price"] ;
  17. header("location:/quickshops/seller/tutoadd.php");
  18.  
  19. }
  20. else
  21. {
  22. echo "Records added successfully.";
  23. }
  24. }
Add Comment
Please, Sign In to add comment