Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <h1>HOP create catogory</h1>
  2. <h3 class="title">create new category</h3>
  3. <p>CRUD demonstration for final exam by Snezana Ilic</p>
  4. <?php
  5.  
  6. require_once 'conn.php'; // establish db connection
  7.  
  8. $cattype = filter_input(INPUT_POST, 'cat_type') or die(' fejl i cat_type');
  9.  
  10. $sql = 'INSERT INTO wp2_category ( cat_type ) VALUES ( ? )';
  11.  
  12. $stmt = $link->prepare($sql);
  13. $stmt->bind_param('s', $cattype);
  14. $stmt->execute();
  15.  
  16. header('location:hop-admin-create.php');
  17. //echo 'inserted resource name '.$cattype.' as id:'.($stmt->insert_id); // id for inserted record
  18.  
  19. ?>
  20. <?php
  21. $pageTitle = "Create category";
  22. require_once 'conn.php';
  23. $form_submit === FALSE;
  24. ?>
  25. <h2>Create category</h2>
  26. <?php if($form_submit === FALSE){ ?>
  27. <form action="" method="post">
  28. Category name* <br>
  29. <input type="text" name="cat_type" value=""><br>
  30. <br>
  31. <input type="submit" name="submitcreate" value="Add new gategory">
  32. </form>
  33.  
  34. <?php
  35. }else{
  36. require_once 'conn.php'; // establish db connection
  37.  
  38. $cattype = filter_input(INPUT_POST, 'cat_type') or die(' fejl i cat_type');
  39.  
  40. $sql = 'INSERT INTO wp2_category ( cat_type ) VALUES ( ? )';
  41.  
  42. $stmt = $link->prepare($sql);
  43. $stmt->bind_param('s', $cattype);
  44. $stmt->execute();
  45.  
  46. //header('location:hop-admin-create.php');
  47. //echo 'inserted resource name '.$cattype.' as id:'.($stmt->insert_id); // id for inserted record
  48.  
  49.  
  50. $pageTitle = "Create category";
  51. require_once 'conn.php';
  52.  
  53. ?>
  54. <h2>Create category</h2>
  55.  
  56. <form action="" method="post">
  57. Category name* <br>
  58. <input type="text" name="cat_type" value="create">
  59. <br>
  60. <input type="submit" name="submitcreate" value="Add new gategory">
  61. </form>
  62. <?php
  63. }
  64.  
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement