added php

This commit is contained in:
lukas-heiligenbrunner 2020-03-31 19:22:08 +02:00
parent 237a5742cf
commit c3f87841d7
3 changed files with 28 additions and 9 deletions

View File

@ -10,6 +10,7 @@ class Req {
xhttp.onerror = function () {
console.log("error")
};
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(data);
}

View File

@ -1,9 +1,9 @@
Req.ready((event) => {
Req.post("php/movie.php", "action=getMovies", function (dta) {
Req.post("php/movie.php", "action=getMovies&test=2", function (dta) {
console.log(dta);
// for (const ii in dta.movies) {
// document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
// <div class="mediatile">${dta.movies[ii].title}</div>`);
// }
for (const ii in dta.data) {
document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
<div class="mediatile">${dta.data[ii].url}</div> <video controls src="${dta.data[ii].url}"></video>`);
}
});
});

View File

@ -1,6 +1,24 @@
<?php
$servername = "192.168.0.177";
$username = "myuser";
$password = "1qayxsw2";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if (isset($_POST['action'])) {
echo("{'data':[{'url':'./vid.mp4'}]}");
}else{
echo("{'data':'$_POST[0]'}");
$action = $_POST['action'];
switch ($action) {
case "getMovies":
echo('{"data":[{"url":"./vid.mp4"}]}');
break;
}
} else {
if ($conn->connect_error) {
echo('{"data":"error"}');
// die("Connection failed: " . $conn->connect_error);
}
}