Guest User

Untitled

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