Guest User

Untitled

a guest
Dec 10th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <?php
  2. $get_post = (int)$_GET['post'];
  3. $pega_post = mysql_query("SELECT * FROM princi WHERE id = '$get_post'");
  4. while($linha = mysql_fetch_array($pega_post)){
  5. ?>
  6. <h1>Ediçao - <?php echo $linha['titu'];?></h1>
  7. <div id="editPost">
  8. <form action="" method="post" enctype="multipart/form-data"/>
  9. <label>
  10. <span class="title">Titulo</span>
  11. <input type="text" name="title" value="<?php echo $linha['titu'];?>"/>
  12. </label>
  13. <label>
  14. <span class="title">Subtitulo</span>
  15. <input type="text" name="sub" value="<?php echo $linha['subti'];?>"/>
  16. </label>
  17. <label>
  18. <span class="title">Categoria</span>
  19. <select name="cat"/>
  20. <?php
  21. $pega_cats = mysql_query("SELECT id,nome FROM categorias ORDER BY id DESC");
  22. while($linhas = mysql_fetch_array($pega_cats)){
  23. ?>
  24. <option value="<?php echo $linhas['id'];?>" <?php if($linhas['id'] == $linha['categoria']){echo 'selected="selected"';}?>><?php echo $linhas['nome'];?></option>
  25. <?php }?>
  26. </select>
  27. </label>
  28. <label>
  29. <textarea name="conteudo" cols="30" rows="5">
  30. <?php echo $linha['conteudo'];?>
  31. </textarea>
  32. </label>
  33. <input type="hidden" name="acao" value="publicar" />
  34. <input type="submit" value="Publicar Postagem" class="send"/>
  35. </form>
  36. </div><!--- Editar Postagem ---->
  37.  
  38. <?php }?>
  39.  
  40.  
  41. <?php if(isset($_POST['acao']) && $_POST['acao'] == 'publicar'){
  42. $title = strip_tags(trim($_POST['title']));
  43. $subti = strip_tags(trim($_POST['subti']));
  44. $categoria = $_POST['cat'];
  45. $conteudo = htmlentities($_POST['conteudo'], ENT_QUOTES);
  46.  
  47. $setPost = mysql_query("UPDATE princi SET titu = '$title',subti = '$subti', categoria = '$categoria', conteudo = '$conteudo' WHERE id = '$get_post'");
  48. if($setPost){
  49. echo '<script>alert("Postagem Atualizada com sucesso!");location.href="?pg=editarDesq"</script>';
  50. }else{}
  51. }
  52. ?>
Add Comment
Please, Sign In to add comment