Hi! my first time here. i'm new to programming. I have a code which checks if a .txt and .jpg file exist in the same folder.(this part is working well) after checking it needs to display the value of .txt file and the .jpg file inside a modal popup. (in my code i tried using an alert box, but as i said it needs to be a modal pop up) i tried echoing the function for modal popup but it displays the code instead of the image. i also want to format the modal popup where the .jpg displays on the left side and the .txt value is on the right. hope you can help me with this. Thanks a lot in advance! here's my code:
index.php
<script>
function readexisting() {
jQuery.ajax({
type: "POST",
url: 'controller.php',
data: {action: 'readexisting', arguments: 'your data'},
success:function(data) {
data = data.split("~:~");
alert(data[0]); // message
//alert(data[1]); // content
}
});
}
</script>
controller.php
<?php
include_once("model.php");
$obj = new Model();
switch($_POST["action"]){
case 'readexisting':
$obj->readexisting();
break;
}
?>
execute.php
<style type="text/CSS">
#overlay {
display: block;
position: absolute;
left: 0px;
top: 0px;
width:100%;
height:100%;
text-align:center;
z-index: 1500;
visibility:hidden;
/*background-image:url(ThankYou.png);*/
}
#overlay div {
width:800px;
margin: 100px auto;
background-color: none;/*rgba(255, 255, 255, 0.9)*/
border:none;
padding:15px;
text-align:center;
}
</style>
<script type="text/javascript">
function overlay() {
el = document.getElementById("overlay");
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
</script>
</head>
<body>
<div id="overlay">
<div>
<img src="events/event-01.jpg" alt="module" style="width:230px; height:313px;">
<p><a href='#close' onclick='overlay()'><img src="images/close_btn.png" alt="module" style="width:15px; height:15px; position:relative; margin-left: 380px; top: -317px;"></a></p>
</div>
</body>
</html>
<?php
class Model {
public function readexisting() {
if (file_exists($_SERVER['DOCUMENT_ROOT']."/Project/events/folder-01/event-01.txt") && file_exists($_SERVER['DOCUMENT_ROOT']."/Project/events/folder-01/event-01.jpg")) {
echo "<script>";
echo "overlay();";
echo "</script>";
$myFile = ($_SERVER['DOCUMENT_ROOT']."/Project/events/folder-01/event-01.txt");
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
}
else {
echo "The file $myFile does not exist";
}
}
}
?>