Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con=mysqli_connect("host", "user", "password", "db");
- $Username = $_POST["Username"];
- $Password = $_POST["Password"];
- $statement = mysqli_prepare($con, "SELECT * FROM User_info WHERE Username = ? AND Password = ?");
- mysqli_stmt_bind_param($statement, "ss", $Username, $Password);
- mysqli_stmt_execute($statement);
- mysqli_stmt_store_result($statement);
- mysqli_stmt_bind_result($statement, $User_id, $Firstname, $Lastname, $Age, $School, $Stype, $Email, $Username, $Password, $Join_Date, $Last_Login);
- $response = array();
- $response["success"] = false;
- while(mysqli_stmt_fetch($statement)){
- $response["success"] = true;
- $response["Firstname"] = $Firstname;
- $response["Lastname"] = $Lastname;
- $response["Age"] = $Age;
- $response["School"] = $School;
- $response["Stype"] = $Stype;
- $response["Email"] = $Email;
- $response["Username"] = $Username;
- $response["Password"] = $Password;
- }
- echo json_encode($response);
- ?>
- <?php
- if($_SERVER['REQUEST_METHOD']=='POST'){
- $image = $_POST['image'];
- $Title = $_POST['Title'];
- $Description = $_POST['Description'];
- require_once('DatabaseConnect.php');
- $sql ="SELECT id FROM Photos ORDER BY id ASC";
- $res = mysqli_query($con,$sql);
- $id = 0;
- while($row = mysqli_fetch_array($res)){
- $id = $row['id'];
- }
- $path = "uploads/$id.png";
- $actualpath = "http://opuna.co.uk/$path";
- $sql = "INSERT INTO Photos (image,Title,Description) VALUES ('$actualpath','$Title', '$Description')";
- if(mysqli_query($con,$sql)){
- file_put_contents($path,base64_decode($image));
- echo "Successfully Uploaded";
- }
- mysqli_close($con);
- }else{
- echo "Error";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement