Okay I have a database where it stores the users information, like their login name, email, and password.
They can upload videos to my site, when they upload the videos, it saves to a database, the database is
set up like this,

     VIDEONAME               EMAIL                     NAME
      funny              sample@email.com            abcd.mp4

It stores the users email who posted the video, and it saves the location of the video when it was uploaded, which is the field called NAME and it saves the name the user gave it once he uploaded the video. Which is VIDEONAME.

Now the user can view his the videos he uploaded from this webpage,

<?PHP
require_once("./include/membersite_config.php");

if(!$fgmembersite->CheckLogin())
{
    $fgmembersite->RedirectToURL("login.php");
    exit;
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
      <title>An Access Controlled Page</title>
      <link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css">
</head>
<body>

<img src="style/RadHalfsLogo.png" id="background" alt="Background Image for Web page" />



<div id="access_controlled">
<div id='fg_membersite_content'>

<p>
Logged in as: <?= $fgmembersite->UserFullName() ?>
<div id="videos_uploaded">
<!-- This is the function that is called which displays all of the users video-->
<?= $fgmembersite->VideosUserUploaded() ?>
</div>
</p>
</div>
</div>
</body>
</html>

Now comes the tricky part. The function which displays the name of the videos which the user uploaded
is this script below,

<?php
session_start();
$email=$_SESSION['email_of_user'];
$con = mysql_connect("hostname.com","username","password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("radhalfs", $con);
$result = mysql_query("
SELECT videos.videoname,videos.name
FROM videos,
fgusers3
WHERE videos.email='$email' AND fgusers3.email='$email'
");
echo "Uploaded Videos";
while ($row = mysql_fetch_array($result)) {
$link=$row['videoname'];
$file_location=$row['name'];
echo "<div id=\"videos_uploaded_by_user\">";
echo "<a href='uploads/upload/browseplayer.html'>$link</a>";
echo "</div>";
}
mysql_close($con); 
?>

Now, this code connects to the database and displays all of the information where the current users email matches the emails in the table which stores the videos name and location, I showed that table above.
In my table example a user saved their video as funny, but its location is abcd.mp4, so I want when the
user clicks on the hyperlink that says funny to have them redirected to this page, and have the name abcd.mp4 be inputed into the src spot.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>
<video controls="controls" src="<!-- This is the src spot-->"> </video>
</body>
</html>

I was thinking if there was a way to do it with cookies, but am not sure how to do so, because every video which is displayed onto the webpage doesnt have its own varaible, it is just saved as $link and the location of the video isnt linked with the video name. So can somone please help.

Member Avatar for LastMitch

@garyjohnson

I was thinking if there was a way to do it with cookies, but am not sure how to do so, because every video which is displayed onto the webpage doesnt have its own varaible, it is just saved as $link and the location of the video isnt linked with the video name. So can somone please help.

First off, I feel you don't understand how the cookies works.

Here is some links:

http://www.tizag.com/phpT/phpcookies.php

http://www.php.net/manual/en/function.setcookie.php

http://www.php.net/manual/en/function.setrawcookie.php

it will give you some better understanding how it works and where to put the code.

The easiest method would be to pass the video name, real or alternate, to the page where it will be played, and then to embed the video. E.g.

<a href='uploads/upload/browseplayer.php?video=funny'>funny</a>

Then within the browseplayer.php script, using the $_GET['video'] parameter, query the database, find the actual file name and output it in the source attribute.

commented: Wow, that is cool! It's much better than the cookie option +3
Member Avatar for LastMitch

@garyjohnson

Have you fixed the video player? The last time we spoken is that you can't make the video player play. If you didn't fixed it yet, then blocblue code will work but I don't think it will play the video from the database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.