Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <html>
  2. <?php
  3. $con = new PDO("mysql:host=localhost;dbname=employees", "root","");
  4. $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  5.  
  6. $statement = $con->prepare("SELECT idISO, name FROM iso");
  7. $statement->execute();
  8.  
  9. $countries = $statement->fetchALL(PDO::FETCH_OBJ);
  10.  
  11.  
  12. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  13.  
  14. $name = $_POST["personname"];
  15. $idISO = $_POST["idISO"];
  16. $namee = $_POST["name"];
  17. $codee = $_POST["code"];
  18.  
  19. //var_dump($countryId);
  20. //var_dump($name;
  21.  
  22. $statement = $con->prepare("INSERT INTO iso(personname, idISO, name, code) VALUES(?, ?, ?, ?)");
  23. $statement->bindValue(1, $name);
  24. $statement->bindValue(2, $idISO);
  25. $statement->bindValue(3, $namee);
  26. $statement->bindValue(4, $codee);
  27.  
  28.  
  29.  
  30. $statement->execute();
  31.  
  32. }
  33.  
  34. ?>
  35. <head>
  36.  
  37. </head>
  38. <body>
  39. <form method ="post">
  40.  
  41. <input type="text" name="personname">
  42. <input type="text" name="code">
  43.  
  44.  
  45.  
  46.  
  47. <select name ="idISO">
  48.  
  49.  
  50. <?php
  51. foreach($countries as $country)
  52. {
  53. echo "<option value='$country->idIso'>$country->name</option>";
  54. }
  55.  
  56.  
  57. ?>
  58.  
  59.  
  60.  
  61. </select>
  62. <input type="submit" name="name" value = "sla op">
  63.  
  64. </form>
  65. <select>
  66.  
  67.  
  68. </select>
  69.  
  70. </body>
  71.  
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement