asimryu

write_ok.php

Feb 9th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $username = "";
  4. $userid = "";
  5. $title = "";
  6. $content = "";
  7. $upfile = "";
  8.  
  9. if( isset($_FILES['upfile']) ) {
  10. if( $_FILES['upfile']['name'] ) {
  11. $path = "../data/";
  12. $filename = $_FILES['upfile']['name'];
  13. $savefile = $path . $filename;
  14. if( move_uploaded_file($_FILES['upfile']['tmp_name'], $savefile) ){
  15. $upfile = $filename;
  16. }
  17. }
  18. }
  19.  
  20.  
  21. if( isset($_POST['username']) ){
  22. $username = $_POST['username'];
  23. }
  24. if( isset($_POST['userid']) ){
  25. $userid = $_POST['userid'];
  26. }
  27. if( isset($_POST['title']) ){
  28. $title = $_POST['title'];
  29. }
  30. if( isset($_POST['content']) ){
  31. $content = $_POST['content'];
  32. }
  33.  
  34. if( $username && $userid && $title && $content ) {
  35. $sql = "insert into blog set ";
  36. $sql .= " username='{$username}' ";
  37. $sql .= ", userid='{$userid}' ";
  38. $sql .= ", title='{$title}' ";
  39. $sql .= ", content='{$content}' ";
  40. $sql .= ", upfile='{$upfile}' ";
  41. $sql .= ", wdate=now()";
  42. include("../lib/dbcon.php");
  43. if( $db->query($sql) ) {
  44. header("Location: /blog/");
  45. } else {
  46. header("Location: /blog/pages/write.php");
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment