added php
This commit is contained in:
		@@ -10,6 +10,7 @@ class Req {
 | 
				
			|||||||
        xhttp.onerror = function () {
 | 
					        xhttp.onerror = function () {
 | 
				
			||||||
            console.log("error")
 | 
					            console.log("error")
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					        xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 | 
				
			||||||
        xhttp.send(data);
 | 
					        xhttp.send(data);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								js/index.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								js/index.js
									
									
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
				
			|||||||
Req.ready((event) => {
 | 
					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);
 | 
					        console.log(dta);
 | 
				
			||||||
        // for (const ii in dta.movies) {
 | 
					        for (const ii in dta.data) {
 | 
				
			||||||
        //     document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
 | 
					            document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
 | 
				
			||||||
        //     <div class="mediatile">${dta.movies[ii].title}</div>`);
 | 
					            <div class="mediatile">${dta.data[ii].url}</div> <video controls src="${dta.data[ii].url}"></video>`);
 | 
				
			||||||
        // }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
@@ -1,6 +1,24 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
if(isset($_POST['action'])){
 | 
					$servername = "192.168.0.177";
 | 
				
			||||||
    echo("{'data':[{'url':'./vid.mp4'}]}");
 | 
					$username = "myuser";
 | 
				
			||||||
}else{
 | 
					$password = "1qayxsw2";
 | 
				
			||||||
    echo("{'data':'$_POST[0]'}");
 | 
					
 | 
				
			||||||
 | 
					// Create connection
 | 
				
			||||||
 | 
					$conn = new mysqli($servername, $username, $password);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Check connection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if (isset($_POST['action'])) {
 | 
				
			||||||
 | 
					    $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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user