I wish to Upload, display and play videos in my website. Here I am able to upload video's url and id into my table. But the problem is video's name is not inserting into table. The video are not uploading into specified directory and I hope because of this Videos are not playing. Please help me to overcome these problems.
My Code is:
dashboard.php
Code:<div class="row"> <?php $conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection Server" . mysqli_error()); $query=mysqli_query($conn, "SELECT * FROM vid"); $id = (isset($_GET['id']) ? $_GET['id'] : ''); if(isset($_POST['submit'])) { echo "<br />".$id."has been uploaded"; } ?> <div> <h3>List Of Videos</h3><br /> <?php $conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection Server" . mysqli_error()); $query=mysqli_query($conn, "SELECT * FROM vid"); while($row=mysqli_fetch_assoc($query)) { $id = $row['id']; $name = $row['name']; $url = $row['url']; echo "<a href='watch.php id=$id'> $id $name $url</a> <br />"; } ?> </div> index.php <?php $conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection Server" . mysqli_error()); if(isset($_POST['submit'])) { $id = (isset($_FILES['file']['id']) ? $_FILES['file']['id'] : ''); $name = (isset($_FILES['file']['name']) ? $_FILES['file']['name'] : ''); $temp = (isset($_FILES['file']['tmp_name']) ? $_FILES['file']['tmp_name'] : ''); move_uploaded_file($temp,"uploaded/".$name); $url = "127.0.0.1/PHP/video%20upload%20and%20playback/uploaded*/…"; mysqli_query($conn, "INSERT INTO vid VALUE('$id','$name','$url') "); header("location:dashboard.php"); } ?> watch.php <?php $conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection Server" . mysqli_error()); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Watch videos</title> </head> <body> <?php $conn = mysqli_connect("localhost", "root", "", "videos") or die("Connection Server" . mysqli_error()); if(isset($_GET['id'])) { $id=(isset($_GET['id']) ? $_GET['id'] : ''); $query=mysqli_query($conn, "SELECT * FROM vid WHERE id='$id'"); while($row=mysqli_fetch_assoc($query)) { $id = $row['id']; $name = $row['name']; $url = $row['url']; echo "You are watching ".$name."<br />"; echo "<embed src='$id' width='560' height='315'></embed>"; } } else { echo "Error !"; } ?> </body> </html>



Reply With Quote
Bookmarks