To print image in certain div, basically what I'm doing it's: echo first part of html page before that "div" (myGallery.html)/ then php script -> echo images from secure folder outside of public_html/ then second part of html (myGallery1.html) after specific "div". Please give me some basic idea how to do it in normal way.
<?php
$userMail = $_POST["email"] = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$password = $_POST["pass"] = filter_var($_POST['password'], FILTER_SANITIZE_STRING);
$userMail = strtolower("$userMail");
$userMail = stripcslashes($userMail);
$password = stripcslashes($password);
$database = file_get_contents( "/home/customer/www/domain/System/sysData.json");
$obj = json_decode($database);
$dbusername = $obj->username;
$dbpassword = $obj->password;
$my_db = $obj->my_db;
$conn = new mysqli("localhost", $dbusername, $dbpassword, $my_db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, username, email, password FROM customers";
$result = $conn->query($sql);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
if ($row["email"] == $userMail && $row["password"] == $password) {
echo "Login Succes". "<br>";
$gal = file_get_contents( "/home/customer/www/domain/public_html/Log/myGallery.html");
echo $gal;
$dir = "/home/customer/www/domain/myGallery";
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
if ($file == '.' or $file == '..') continue;
$path = '/home/customer/www/domain/myGallery/'. $file;
$imgData = base64_encode(file_get_contents($path));
$src = 'data: '.mime_content_type($path).';base64,'.$imgData;
echo "<img class=\"images\" src=\"$src\" data=\"$file\" >";
}
closedir($dh);
}
};
$gal1 = file_get_contents( "/home/customer/www/domain/public_html/Log/myGallery1.html");
echo $gal1;
} else {
echo "Failed to LogIn";
};
$conn->close();
?>