Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Błąd... Co i jak? renderForm, problem z funkcja renderForm
Waloch016
post
Post #1





Grupa: Zarejestrowani
Postów: 110
Pomógł: 0
Dołączył: 2.10.2010
Skąd: Irlandia

Ostrzeżenie: (0%)
-----


Mam problem cały czas pokazuje mi łąd że błędne zapytanie do niezdefiniowanej funkji render form. w linji 79

  1. <?php /*
  2.  
  3.   EDIT RECORD
  4.  
  5.   */
  6. // if the 'id' variable is set in the URL, we know that we need to edit a record
  7.  
  8. include('db.php');
  9.  
  10. if (isset($_GET['id']))
  11. {
  12. // if the form's submit button is clicked, we need to process the form
  13. if (isset($_POST['submit']))
  14. {
  15. // make sure the 'id' in the URL is valid
  16. if (is_numeric($_POST['id']))
  17. {
  18. // get variables from the URL/form
  19.  
  20. $car = $_POST['car'];
  21. $date = $_POST['date'];
  22. $time = $_POST['time'];
  23. $number = $_POST['number'];
  24. $name = $_POST['name'];
  25. $type = $_POST['type'];
  26. $price = $_POST['price'];
  27.  
  28. // check that firstname and lastname are both not empty
  29. if ($car == '' || $date == '' || $time == '' || $number == '' || $name == '' || $type =='' || $price == '')
  30. {
  31. // if they are empty, show an error message and display the form
  32. $error = 'ERROR: Please fill in all required fields!';
  33. renderForm($car, $date, $time, $number, $name, $type, $price, $error, $id);
  34. }
  35. else
  36. {
  37. // if everything is fine, update the record in the database
  38. if ($stmt = $conn->prepare("UPDATE `booking` SET car = ?, date = ?, time = ?, number = ?, name = ?, type = ?, price = ?
  39. WHERE id=?"))
  40. {
  41. $stmt->bind_param("sssi", $car, $date, $time, $number, $name, $type, $price, $id);
  42. $stmt->execute();
  43. $stmt->close();
  44. }
  45. // show an error message if the query has an error
  46. else
  47. {
  48. echo "ERROR: could not prepare SQL statement.";
  49. }
  50.  
  51. // redirect the user once the form is updated
  52. header("Location: booking.php");
  53. }
  54. }
  55. // if the 'id' variable is not valid, show an error message
  56. else
  57. {
  58. echo "Error!";
  59. }
  60. }
  61. // if the form hasn't been submitted yet, get the info from the database and show the form
  62. else
  63. {
  64. // make sure the 'id' value is valid
  65.  
  66. // get 'id' from URL
  67. $id = $_GET['id'];
  68.  
  69. // get the recod from the database
  70. if($stmt = $conn->prepare("SELECT * FROM `booking` WHERE id=?"))
  71. {
  72. $stmt->bind_param("i", $id);
  73. $stmt->execute();
  74.  
  75. $stmt->bind_result($car, $date, $time, $number, $name, $type, $price, $id);
  76. $stmt->fetch();
  77.  
  78. // show the form
  79. renderForm($car, $date, $time, $number, $name, $type, $price, NULL, $id);
  80. $conn->close();
  81. }
  82. // show an error if the query has an error
  83. else
  84. {
  85. echo "Error: could not prepare SQL statement";
  86. }
  87.  
  88. // if the 'id' value is not valid, redirect the user back to the view.php page
  89.  
  90. header("Location: booking.php");
  91.  
  92. }
  93. }
  94.  
  95. ?>
  96.  
Ktos podpowie, pomoze?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 19:42