Guest User

Untitled

a guest
Jan 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. if (!empty($_POST['formCategoria'])) {
  5.  
  6. include '../fn.php';
  7.  
  8.  
  9. if (empty($_POST['categoria_id'])) {
  10. s("INSERT INTO categoria (categoria_id) VALUES (NULL)");
  11. $f = f("SELECT categoria_id FROM categoria ORDER BY id DESC LIMIT 1");
  12. $_POST['id'] = $f['id'];
  13. }
  14. $categoria_id="";
  15. if (!empty($_POST['categoria_id'])) {
  16. $categoria_id=" categoria_id='" . $_POST['categoria_id'] . "', ";
  17. }
  18.  
  19. s("UPDATE categoria SET
  20. ".$categoria_id."
  21. categoria_id='" . $_POST['categoria_id'] . "'
  22. WHERE id='" . $_POST['id'] . "'
  23. ");
  24. ?>
  25. <script>
  26. window.alert('Atualizado');
  27. window.location = '../categorias';
  28. </script>
  29. <?php
  30. exit;
  31. }
  32.  
  33. if (!empty($_GET['categora_id'])) {
  34. $categoria = f("SELECT * FROM categoria WHERE id=" . $_GET['categoria_id']);
  35. }
  36. ?>
  37. <div class="row">
  38. <div class="container">
  39. <div class="col-md-12">
  40.  
  41. <h3>Subcategoria</h3>
  42.  
  43. <a class="btn btn-xs btn-default" href="<?php echo $root; ?>categorias">Voltar</a>
  44.  
  45. <div class="br2"></div>
  46. <div class="row">
  47. <form id="formCategoria" action="<?php echo $root; ?>pg/edita-subcategoria.php" method="post">
  48. <input type="hidden" name="formCategoria" value="ok">
  49. <?php
  50. if (!empty($_GET['id'])) {
  51. ?>
  52. <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
  53. <?php
  54. }
  55. ?>
  56. <div class="col-md-3">
  57. <div class="form-group">
  58. <label>Subcategoria</label>
  59. <input class="form-control" type="text" name="categoria_id"
  60. value="<?php echo!empty($categoria_id['categoria_id']) ? $categoria_id['categoria_id'] : ''; ?>">
  61. </div>
  62. </div>
  63.  
  64. <div class="br2"></div>
  65. <div class="col-md-12">
  66. <div class="div-right">
  67. <input type="submit" class="btn btn-default" value="<?php echo empty($_GET['id'])?'Cadastrar':'Atualizar'; ?>">
  68. </div>
  69. </div>
  70. <div class="br2"></div>
  71. <div class="br2"></div>
  72. </form>
  73. </div>
  74. </div>
  75. </div>
Add Comment
Please, Sign In to add comment