Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4.  
  5. </head>
  6. <body>
  7.  
  8. <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  9. Customer Number: <input type="text" name="name" value="<?php echo $name;?>">
  10. <input type="submit" name="submit" value="Submit">
  11. </form>
  12.  
  13. <?php
  14. $name = "";
  15.  
  16. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  17. if (!empty($_POST["name"])) {
  18. $name = $_POST["name"];
  19. }
  20. }
  21. $promenliva = "";
  22.  
  23. $conn = mysqli_connect("127.0.0.1", "test_php", "TestPassword22.", "classicmodels");
  24.  
  25. if (!$conn) {
  26. die("Connection failed: >>>" . mysqli_connect_error());
  27. }
  28.  
  29. $sql = "select * from customers where customerNumber=".$name;
  30. $result = $conn->query($sql);
  31.  
  32. if ($result->num_rows > 0) {
  33. while($row = $result->fetch_assoc()) {
  34. //echo "Customer Name: " . $row["customerName"]. " - Credit Limit: " . $row["creditLimit"]. "<br>";
  35. $promenliva=$row["customerName"];
  36. }
  37. } else {
  38. echo "0 results";
  39. }
  40. $conn->close();
  41. echo "<h2>Customer (company) name: </h2>"."<h1>".$promenliva."</h1>";
  42. ?>
  43.  
  44.  
  45.  
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement