Guest User

Untitled

a guest
Jun 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2. echo "sdfsfd";
  3. include "DBCONNECT.php";
  4.  
  5. $tblname = "stories";
  6. session_start();
  7.  
  8. function get_image_extension($filename)
  9. {
  10. $tempArray = explode(".",$filename);
  11. return $tempArray[1];
  12. }
  13.  
  14. function extValid($fileString){
  15. $fileString = strtolower($fileString);
  16. if($fileString == "jpg" || $fileString == "jpeg" || $fileString == "png" || $fileString == "gif"){
  17. return true;
  18. } else{
  19. return false;
  20. }
  21. }
  22.  
  23. if($story1 != '' && $story2 != '' && $story3 != ''){
  24. if(isset($_POST['rating'])){
  25. if(isset($_POST['category']) && $_POST['category'] != ""){
  26. if(isset($_SESSION['username'])){
  27.  
  28. $user = $_SESSION['username'];
  29. $date = date("M j, Y");
  30. $story = $_POST['story1']." - ".$_POST['story2']." - ".$_POST['story3'];
  31. $rating = $_POST['rating'];
  32. $category = $_POST['category'];
  33.  
  34. $ext = get_image_extension(($_FILES['file']['name']));
  35. $file_name = md5(rand(900000000,1000000000));
  36.  
  37. $validExtension = extValid($ext);
  38.  
  39. if($validExtension == true){
  40. echo "upload complete";
  41. move_uploaded_file($_FILES['file']['tmp_name'],"user_uploads/".$file_name.".".$ext));
  42. }else{
  43. echo "invalid extension.";
  44. }
  45.  
  46. //$sql = "INSERT INTO stories VALUES('','$user','$date','$story','$user','$rating','0','0','0','$category')";
  47. mysql_query($sql);
  48.  
  49.  
  50. //header("Location: index.php?pid=");
  51. }
  52. }else{
  53. //header("Location: index.php?pid=errormessage&message=You must select a category.");
  54. }
  55. }else{
  56. //header("Location: index.php?pid=errormessage&message=You must select a degree rating.");
  57. }
  58. }else{
  59. //header("Location: index.php?pid=errormessage&message=You must fill out all of the story fields.");
  60. }
  61. ?>
Add Comment
Please, Sign In to add comment