This is really hard to explain but I am going to try me best,
I have an html page which displays a video player named brosweplayer.html,
the code is this,

<!DOCTYPE html>
<html lang="en">

<head>

<title>Untitled Document</title>

<meta charset="utf-8"/>

</head>

<body>

<video src="$name" controls="controls">

</body>
</html>

Now, I also have a php script which selects data from my database and displays
the results onto another webpage which is the users account page. The code is this,

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); 

What it displays is the name of all the videos which the user uploaded in hyperlinks,
but the user gave the videos fake names when they uploaded them. This is so the videos
would be easier to read, they are displayed as 'videoname' in the code.
It also selects the real name of the video, which is displayed as 'name' in the code.
The real name of the video is the name they are saved as in my directory.

What I want is for when the user clicks on one of their many video hyperlinks
to have them redirected to the browseplayer.html file so the video will be played.
But it has to play the video which was being displayed on the hyperlink, on the webpage.

For an example, lets say the user uploaded a video with a real name of win.mp4,
he then renames the video to Funny. That video is saved to my directory as win.mp4.
The name Funny and win.mp4 are saved into a database.
The user then goes to see all the videos which he uploaded,
it displays all of his videos in hyperlinks, which display the fake name given by the user,
so in this case it displays Funny in a hyperlink. He then clicks on that link and it
redirects him to browseplayer.html where is plays the video win.mp4.

I hope you understood what I am trying to ask. If you think you can help leave some comments,
and if you didnt understand some parts of what I was saying, let me know and I will try to
clarify them with you. Thanks a lot.

Member Avatar for LastMitch

@garyjohnson

What I want is for when the user clicks on one of their many video hyperlinks
to have them redirected to the browseplayer.html file so the video will be played.
But it has to play the video which was being displayed on the hyperlink, on the webpage.

Are these code on the same webpage or separate? Plus where is your upload form?

1) upload form
2) is this file:

<?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); 
?>

3) is this

<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>
<video controls="controls" src="<?php echo $name; ?>">
</body>
</html>

I hope that will give you idea how to works it. It's a bit confusing, this is what I put together in order to work. It has be in sequence in order for this to work. I don't want you to get offended but the files are not in sequence.

My upload form is on a completely different webpage,
but it is this,

$allowedExts = array("mp4", "mov", "avi", "flv","mpg", "wmv", "3gp", "rm");
$extension = end(explode(".", $_FILES["file"]["name"]));
if (($_FILES["file"]["size"] < 90000000000000000000000000000000000)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "uploads/upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "uploads/upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }

This script below, is a function named, ListOfUsersVideos();

<?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); 
?>

This File is located in seperate folder which handles all my php script.
So, when I want to display all my users videos I just call that function.
What that function does is displays all the users uploaded videos in hyperlinks
where they can click them and be redirected to brosweplayer.html. But once they
are redicrected, to this page,

<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>
<!-- Here is where the real name of the video needs to be inputed. 
     Directly into the source spot. Does this format work?-->
<video controls="controls" src="<?php echo $file_location; ?>">
</body>
</html>

It must put the real file location into the source spot. As shown in the
comment above.

Member Avatar for LastMitch

@garyjohnson

I hope you understood what I am trying to ask. If you think you can help leave some comments,and if you didnt understand some parts of what I was saying, let me know and I will try to clarify them with you. Thanks a lot.

This is very confusing. I don't know what you are trying to accomplish here.

For an example, lets say the user uploaded a video with a real name of win.mp4, he then renames the video to Funny. That video is saved to my directory as win.mp4. The name Funny and win.mp4 are saved into a database. The user then goes to see all the videos which he uploaded, it displays all of his videos in hyperlinks, which display the fake name given by the user,so in this case it displays Funny in a hyperlink. He then clicks on that link and it redirects him to browseplayer.html where is plays the video win.mp4.

1) is the db connected? Does it select the videos.videoname,videos.name FROM videos ?

mysql_select_db("radhalfs", $con);

$result = mysql_query("

SELECT videos.videoname,videos.name FROM videos, fgusers3 WHERE videos.email='$email' AND fgusers3.email='$email'

");

2) does it fetch the data?

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>";
}

3) What does it display here?

<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>

<!-- What is the code for here? -->

<!-- I thought this <?php echo $name; ?> instead of this <?php echo $file_location; ?> was in the src? -->

<video controls="controls" src="<?php echo $file_location; ?>">

</body>
</html>

I not quite sure why you change that? Any reason?

I know this is very confusing. I'll try to walk through it completely.
First, my user logs in, which works completely fine, then he clicks onto his
account page, which is this,

<?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>

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

<p>
Logged in as: <?= $fgmembersite->UserFullName() ?>

<!-- This is where the function VideosUserUploaded() is called -->
<div id="videos_uploaded">
<?= $fgmembersite->VideosUserUploaded() ?>
</div>
</p>
<p>
<a href='login-home.php'>Home</a>
<a href='upload.php'>upload</a>
</p>
</div>
</div>
</body>
</html>

This code also works perfectly fine, What the function does is displays all the videos which the user uploaded, and displays them in hyperlinks, the code for that function is this php code,

function VideosUserUploaded();
<?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); 
?>

This code works perfectly fine as well. As you can see it connects to the database and gets the videoname, and name from the table videos. It then places videoname into a hyperlink text, so the user can see the video they uploaded. They click on one of their many videos and it redirects them to this html page which is suppose to play the video in a video player,

<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>
<!-- This code plays the video, I changed it to $file_location because it should          have never been called $name, that was my fault. As you can see $file_location is a variable which takes its value in the function VideosUsersUploaded(); which is the php code above this code. -->
<video controls="controls" src="<?php echo $file_location; ?>">
</body>
</html>

This code brings up the video player, but it does not play the video which I wanted it to, Its suppose to put the $file_location into the source spot, but the $file_location has to be the same video as the videoname which is displayed in the hyperlinks.

Member Avatar for LastMitch

@garyjohnson

This code brings up the video player, but it does not play the video which I wanted it to, Its suppose to put the $file_location into the source spot, but the $file_location has to be the same video as the videoname which is displayed in the hyperlinks.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8"/>
</head>
<body>
<video controls="controls" src="<?php echo $file_location; ?>">
</body>
</html>

May I ask what kind of player are you using? Is it Flash? Is it mplayer? or vlc player?

It is just the basic HTML 5 video player.

Member Avatar for LastMitch

@garyjohnson

It is just the basic HTML 5 video player.

There is so many out there!

Most of them are similiar to this ... Read and follow the instructions:

http://videojs.com/#section5

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.