Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST["username"]) && isset($_POST["password"])){
  4. // Filter everything except letters and numbers
  5. $user = preg_replace('#^A-Za-z0-9#i','',$_POST["username"]);
  6. $password = preg_replace('#^A-Za-z0-9#i','',$_POST["password"]);
  7.  
  8. // Connect to mySQL
  9. include"assets/scripts/sql_connect.php";
  10.  
  11. // Query the person
  12. $sql = $conn->query("SELECT id FROM user_login WHERE user_name='$user' AND user_password='$password' LIMIT 1");
  13.  
  14. // Make sure person exists
  15. $existCount = $sql->rowCount();
  16.  
  17. // Evaluate the count
  18. if($existCount == 1){
  19. while($row = mysql_fetch_array($sql)){
  20. $id = $row["id"];
  21. }
  22. $_SESSION["id"] = $id;
  23. $_SESSION["user"] = $user;
  24. $_SESSION["password"] = $password;
  25. header("location:index.php");
  26. exit();
  27. }else{
  28. echo"Login details incorrect, try again <a href='index.php'>Click here</a>";
  29. exit();
  30. }
  31. }
  32. ?>
  33.  
  34. <?php
  35. session_start();
  36.  
  37. include"assets/scripts/sql_connect.php";
  38.  
  39. if (isset($_POST['image_title'])){
  40.  
  41. $userid = $_SESSION["id"];
  42. $image_title = $_POST['image_title'];
  43. $image_comment = $_POST['image_comment'];
  44.  
  45.  
  46. //Add image text to the database
  47. $sql = $conn->query("INSERT INTO user_image(user_id,image_title,image_comment, image_date_added) VALUES('$userid','$image_title','$image_comment', now())") or die(mysql_error());
  48. $id = $conn->lastInsertId();
  49.  
  50. $image_id = $conn->lastInsertID();
  51. // Places image in the images folder
  52. $new_name = "$image_id.jpg";
  53. move_uploaded_file($_FILES['app_art_image']['tmp_name'],"appArtImages/$new_name");
  54. header("location:gallery.php");
  55. exit();
  56. }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement