Advertisement
Guest User

Untitled

a guest
Nov 21st, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. <?php include_once 'inc/top.php'; ?>
  2.  
  3. <?php
  4. if (isset($_POST['tuoteryhmat'])) {
  5. try {
  6.  
  7.  
  8. $nimijr = filter_input(INPUT_POST,'nimi',FILTER_SANITIZE_STRING);
  9. $kuvausjr = filter_input(INPUT_POST,'kuvaus',FILTER_SANITIZE_STRING);
  10. $hintajr = filter_input(INPUT_POST,'hinta',FILTER_SANITIZE_NUMBER_INT);
  11. $idjr2 = filter_input(INPUT_POST, 'tuoteryhma_id');
  12.  
  13. $kyselyjr2 = $tietokantajr->prepare("INSERT INTO
  14. tuote (nimi,kuvaus,hinta,tuoteryhma_id) VALUES (:nimi,:kuvaus,:hinta,tuoteryhma_id:)");
  15.  
  16. $kyselyjr2->bindValue(':nimi', $nimijr, PDO::PARAM_STR);
  17. $kyselyjr2->bindValue(':kuvaus', $kuvausjr, PDO::PARAM_STR);
  18. $kyselyjr2->bindValue(':hinta', $hintajr, PDO::PARAM_STR);
  19. $kyselyjr2->bindValue(':tuoteryhma_id', $idjr2, PDO::PARAM_STR);
  20.  
  21.  
  22. $kyselyjr2->execute();
  23.  
  24.  
  25.  
  26. print "<p>Tuote tallennettu onnistuneesti!</p>";
  27. } catch (PDOException $pdoextuotejr) {
  28. print "Tuotteen tallennuksessa tapahtui virhe."
  29. . $pdoextuotejr->getMessage();
  30. }
  31.  
  32.  
  33. }
  34.  
  35. ?>
  36.  
  37.  
  38.  
  39.  
  40. <div class='container'><div class='row'><div class='col-xs-12'></div></div></div><div class="container">
  41. <div class="row">
  42. <div class="col-xs-12">
  43.  
  44.  
  45. <form role="form" action='<?php print($_SERVER['PHP_SELF']); ?>' method='post'>
  46. <input type="hidden" name="id" value="0">
  47. <div class="form-group">
  48. <label for="tuoteryhmat">Select list:</label>
  49. <select class="form-control" name="tuoteryhma_id" value="<?php echo $idjr ?>" id="tuoteryhmat">
  50. <?php
  51. try {
  52.  
  53. $sqljr='SELECT * FROM tuoteryhma';
  54. $kyselyx=$tietokantajr->query($sqljr);
  55.  
  56. while ($tietuejr = $kyselyx->fetch()) {
  57. print '<option>' . $tietuejr['nimi'] . '</option>';
  58. $idjr = $tietuejr['id'];
  59.  
  60. }
  61.  
  62. } catch (PDOException $pdoexjr) {
  63. print "Tietokannan avaus epäonnistui." . $pdoexjr->getMessage();
  64. }
  65.  
  66.  
  67. ?>
  68. </select>
  69. </div>
  70. <div class="form-group">
  71. <label>Nimi</label>
  72. <input name="nimi" id="nimi" value="" class="form-control" required value="">
  73. </div>
  74. <div class="form-group">
  75. <label>Kuvaus</label>
  76. <input name="kuvaus" id="kuvaus" value="" class="form-control" required value="">
  77. </div>
  78. <div class="form-group">
  79. <label>Kuvatiedosto</label>
  80. <input type="file" id="kuva" value="" class="form-control" value="">
  81. </div>
  82. <div class="form-group">
  83. <label>Hinta</label>
  84. <input name="hinta" id="hinta" value="" class="form-control" value="">
  85. </div>
  86. <button type="submit" class="btn btn-primary">Tallenna</button>
  87. <button type="button" class="btn btn-default" onclick="javascript:window.location='index.php';return false;">Peruuta</button>
  88. </form>
  89. </div>
  90. </div>
  91. </div><!-- /.container -->
  92.  
  93.  
  94. <?php include_once 'inc/bottom.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement