Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
188
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. $con=mysqli_connect("host", "user", "password", "db");
  3.  
  4. $Username = $_POST["Username"];
  5. $Password = $_POST["Password"];
  6.  
  7. $statement = mysqli_prepare($con, "SELECT * FROM User_info WHERE Username = ? AND Password = ?");
  8. mysqli_stmt_bind_param($statement, "ss", $Username, $Password);
  9. mysqli_stmt_execute($statement);
  10.  
  11. mysqli_stmt_store_result($statement);
  12. mysqli_stmt_bind_result($statement, $User_id, $Firstname, $Lastname, $Age, $School, $Stype, $Email, $Username, $Password, $Join_Date, $Last_Login);
  13.  
  14. $response = array();
  15. $response["success"] = false;
  16.  
  17.  
  18. while(mysqli_stmt_fetch($statement)){
  19.  
  20. $response["success"] = true;
  21. $response["Firstname"] = $Firstname;
  22. $response["Lastname"] = $Lastname;
  23. $response["Age"] = $Age;
  24. $response["School"] = $School;
  25. $response["Stype"] = $Stype;
  26. $response["Email"] = $Email;
  27. $response["Username"] = $Username;
  28. $response["Password"] = $Password;
  29. }
  30.  
  31. echo json_encode($response);
  32.  
  33. ?>
  34.  
  35. <?php
  36.  
  37. if($_SERVER['REQUEST_METHOD']=='POST'){
  38. $image = $_POST['image'];
  39. $Title = $_POST['Title'];
  40. $Description = $_POST['Description'];
  41.  
  42.  
  43. require_once('DatabaseConnect.php');
  44. $sql ="SELECT id FROM Photos ORDER BY id ASC";
  45. $res = mysqli_query($con,$sql);
  46. $id = 0;
  47. while($row = mysqli_fetch_array($res)){
  48. $id = $row['id'];
  49. }
  50. $path = "uploads/$id.png";
  51.  
  52. $actualpath = "http://opuna.co.uk/$path";
  53.  
  54. $sql = "INSERT INTO Photos (image,Title,Description) VALUES ('$actualpath','$Title', '$Description')";
  55. if(mysqli_query($con,$sql)){
  56. file_put_contents($path,base64_decode($image));
  57. echo "Successfully Uploaded";
  58. }
  59. mysqli_close($con);
  60. }else{
  61. echo "Error";
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement