What's new

Closed help php upload video and play/pause

Status
Not open for further replies.

Megabing213

Eternal Poster
Joined
Mar 18, 2018
Posts
654
Reaction
682
Points
359
bat ayaw po nya mag upload nang video? pa fix po mga sir
database.
ctto.


index.php
Code:
<!DOCTYPE html>
<html>
<head>
    <title>video upload</title>
</head>
<body>
<h1><a href="video.php">VIDEOS</a></h1>

<form method="post" action="index.php" enctype="multipart/form-data">

    <input type="file" name="file">
    <input type="submit" name="upload" value="UPLOAD">

</form>
</body>
</html>


<?php
include ('db.php');

if (isset($_POST['upload'])) {

$name = $_FILES['file']['name'];
$tmp = $_FILES['file']['tmp_name'];

move_uploaded_file($tmp, "videos/".$name);

$sql = "INSERT INTO videos (name) VALUES('$name)";

$res = mysqli_query($con,$sql);

if ($res ==1) {

    echo "<h1>video inserted successfully</h1>";
    
}


}


?>



db.php (database)

Code:
<?php
$con = mysqli_connect('localhost','root','','vuad');

?>
 
okay nasya paps nachange ko na php ini so natatanggap narin yung vid sa database. ang kulang nalang is di ma play yung video ahaha nag create naden ako nang video folder sa htdocs or sa wamp..
ETO YUNG CONNECTION DATABASE.
Code:
<?php
$db_name='anything';
$mysql_user='root';
$mysql_pass='';
$server_name='localhost';

$con =mysqli_connect($server_name, $mysql_user, $mysql_pass, $db_name);

if (!$con) {
    echo "Connection Error Please Contact TST" .mysqli_connect_error();
} else
{
    echo "Connected";
}


?>


ETO NAMAN YUNG INDEX

Code:
<!DOCTYPE html>
<html>
<head>
    <title>video upload</title>
</head>
<body>
<h1><a href="video.php">VIDEOS</a></h1>

<form method="post" action="index.php" enctype="multipart/form-data">

    <input type="file" name="file">
    <input type="submit" name="upload" value="UPLOAD">

</form>
</body>
</html>


<?php
include ('connect.php');

if (isset($_POST['upload'])) {

$name = $_FILES['file']['name'];
$tmp = $_FILES['file']['tmp_name'];

move_uploaded_file($tmp, "videos/".$name);

$sql = "INSERT INTO videos (name) VALUES('$name')";

$res = mysqli_query($con,$sql);

if ($res ==1) {

    echo "<h1>video inserted successfully</h1>";
    
}


}


?>

ETO YUNG VIDEO.PHP

Code:
<?php
include ('connect.php');

$sql = "select * from videos";
$res = mysqli_query($con, $sql);

echo "<h1> MYVIDEOS </h1>";

while ($row = mysqli_fetch_assoc($res)) {

        $id = $row['id'];
        $name = $row['name'];

echo "<h4><a href='watch.php?id=$id'>" .$name. "</a></h4><br/>";
}


?>

WATCH.PHP

Code:
<?php
include ('connect.php');

if (isset($_GET['id'])) {
    $id = $_GET['id'];

$sql = "select name from videos where id='id'";
$res = mysqli_query($con,$sql);

$row = mysqli_fetch_assoc($res);

$name = $row['name'];

echo "<h1>you are watching:".$name."</h1>";

?>

<video width="615" height="315" controls>
    <source src="videos/<?php  echo $name; ?>" type="video/mp4">

</video>

<?php
}
?>
 
1584035410228.png

ayaw nya parin paps. pilitan kona pero parang hindi nareread yung video
 

Attachments

Sorry ts ok na pala yung
Code:
<source src="videos/<?php  echo $name; ?>" type="video/mp4">
ang mali mo pala is sa watch.php mo is ito
Code:
$sql = "select name from videos where id='id'";
and hinahanap mo ay "id" na string hindi yung value ng variable na $id
so ito yung tama
Code:
$sql = "select name from videos where id='$id'";
 
Last edited:
Sorry ts ok na pala yung
Code:
<source src="videos/<?php  echo $name; ?>" type="video/mp4">
ang mali mo pala is sa watch.php mo is ito
Code:
$sql = "select name from videos where id='id'";
and hinahanap mo ay "id" na string hindi yung value ng variable na $id
so ito yung tama
Code:
$sql = "select name from videos where id='$id'";
it's a big thanks for you at salahat nang tumulong ahehe
 
Status
Not open for further replies.

Similar threads

Back
Top