Loading...
Menu

youtube tutorial

YouTube tutorial in php and JavaScript

Thanks for downloading this video sharing tutorial eBook.

You are free to distribute this eBook with your friends and colleagues. We have many tutorials like; how to create a social network tutorial like Facebook in php and JavaScript,

Ho to create twitter tutorial in php and JavaScript,

Ho to create Gmail tutorial in php and JavaScript,

Ho to create twitter web plug-in like who is online.

Visit our website to follow and download all this tutorials for free at www.23tutorials.com. For any question email us at [email protected]

YouTube Tutorial in php and JavaScript

Database………………………………………………………………………

Connection.php………………………………………………………………. 4

Function.php…………………………………………………………………. 5

Index.css………………………………………………………………………. 6

Home.css ……………………………………………………………………… 10

Registration script……………………………………………………………. 31

Login script…………………………………………………………………… 38

How to upload video script………………………………………………….. 43

How to view all uploaded videos script …………………………………….. 49

How to watch videos script…………………………………………………… 52

Uploading profile picture script……………………………………………… 59

Show user profile name / photo script………………………………………. 64

How to search video script……………………………………………………. 67

How to edit video information script………………………………………… 73

How delete video script………………………………………………………. 78

How to add comment to a video script………………………………………. 83

How to bookmark video script……………………………………………….. 92

How to like / dislike video script……………………………………………. 99

How to count video views script……………………………………………. 107

How to view bookmark (favorite) videos script…………………………… 113

How user edit account information………………………………………… 116

connection.php

This php file connects this tutorial to the database.

$mysql_hostname= "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "learn"; //database name, you can change to yours
$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");
?>

 

function.php

This php file stores the login user session.

 

 

include("connection.php");
if(isset($_SESSION["SESS_MEMBER_ID" ] ) ) {
$result = mysql_query("SELECT member_id FROM `member` WHERE `member_id`='".$_SESSION["SESS_MEMBER_ID"]." ' LIMIT 1");
if(mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
$_SESSION["logged"] = $row["member_id"];
}
}
?>

Index.css

This is the index.css for styling the index.php page.

body{

margin-left:-0%;

margin-top:0%;

margin-right:-0%;

background-color:#dddddd;

}

#index_page_header{

position:fixed;

background-color:#e03409;

width:1280px;

height:80px;

top:-21px;

left:0px;

z-index: 2;

}

#registration_div{

background-color:;

width:304px;

height:420px;

position:absolute;

top:95px;

font-weight:bold;

left:7px;

border:1px solid white;

border-radius:5px;

}

h1{

color:white;

}

h2{

position:absolute;

color:green;

font-size:17px;

left:40px;

top:-12px;

}

.reg{

position:relative;

left:3px;

border-radius:4px;

border:0px;

height:30px;

width:295px;

}

#submit_bitton{

position:relative;

background-color:blue;

left:80px;

top:-35px;

border-radius:4px;

border:0px;

height:30px;

width:125px;

color:white;

}

#login_div{

background-color:;

position:absolute;

top:25px;

margin-left:7px;

width:20px;

}

#login_email{

position:relative;

left:3px;

border-radius:0px;

border:0px;

height:25px;

width:298px;

}

#login_password{

position:relative;

top:2px;

left:3px;

border-radius:0px;

border:0px;

height:25px;

width:298px;

}

#login_button{

position:absolute;

background-color:blue;

left:0px;

top:60px;

border-radius:0px;

border:1px solid grey;

height:23px;

width:55px;

color:white;

}

Home.css

Below is the home.css for styling the home page.

/* div containing profile picture */

.profile-photo{

position:absolute;

top:84px;

left:10px;

width:150px;

height:140px;

background-color:white;

border:1px solid #cce;

border-radius:6px;

}

/* profile name */

#profile_name{

position:relative;

top:-27px;

left:2px;

font-size:17px;

}

/* profile picture */

.profile_pic{

position:absolute;

top:4px;

left:4px;

width:142px;

height:132px;

border-radius:6px;

}

/* div for uploading videos */

.upload-video-div{

position:absolute;

top:84px;

left:210px;

width:440px;

height:140px;

background-color:white;

border:1px solid #ccc;

border-radius:6px;

}

/* div for syling uploading forms like youtube */

.fileUpload {

position: relative;

overflow: hidden;

margin: 10px;

background-color:white;

height: 123px;

width: 180px;

text-align: center;

top:-2px;

border:1px solid black;

}

.fileUpload input.upload {

position: absolute;

top: 0;

right: 0;

margin: 0;

padding: 0;

font-size: 20px;

cursor: pointer;

opacity: 0;

filter: alpha(opacity=0);

height: 100%;

text-align: center;

}

.custom-span{ font-family: Arial; font-weight: bold;font-size: 100px; color: #FE57A1}

#uploadFile{border: none;margin-left: 10px; width: 200px;}

.custom-para{font-family: arial;font-weight: bold;font-size: 24px; color:#585858;}

#photo_text{

position:absolute;

width:350px;

height:36px;

left:147px;

top:75px;

font-size:16px;

}

#photo_comment{

position:absolute;

left:150px;

top:30px;

font-size:20px;

}

#submit_photo{

position:absolute;

width:340px;

height:50px;

left:155px;

top:120px;

font-size:24px;

background-color:white;

border:0px solid black;

color:white;

}

.preview

{

position:absolute;

left:185px;

top:-52px;

border:0px solid black;

}

#preview{

position:absolute;

top:60px;

color:#cc0000;

font-size:12px

}

/* end of div for syling uploading forms like youtube */

.left-bar-links{

position:absolute;

width:160px;

height:120px;

left:10px;

top:240px;

font-size:17px;

background-color:#dddddd;

border:0px solid #ccc;

color:black;

}

.left-bar-links a {

text-decoration:none;

color:black;

}

#noticeboard{

width:780px;

height:35px;

border:0px solid #cce;

background-color:;

position:absolute;

left:20px;

top:0px;

}

.content{

width:380px;

margin:0 auto;

position:absolute;

top:37px;

left:190px;

}

#searchid

{

position:absolute;

width:480px;

border:1px solid #cce;

padding:10px;

font-size:14px;

border-radius:5px;

}

#result

{

position:absolute;

width:480px;

padding:10px;

display:none;

top:37px;

border-top:1px;

overflow:hidden;

border:1px #CCC solid;

background-color:#cce;

}

.user-video-upload{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:244px;

margin-left:210px;

width:885px;

border-radius:3px;

border:;

padding:1px;

}

.user-preview{

position:relative;

border:px solid #cce;

border-radius:px;

margin-left:-10px;

}

#native {

-webkit-column-width: 250px;

-moz-column-width: 250px;

-o-column-width: 250px;

-ms-column-width: 250px;

column-width: 250px;

-webkit-column-rule-style: solid;

-moz-column-rule-style: solid;

-o-column-rule-style: solid;

-ms-column-rule-style: solid;

column-rule-style: solid;

float:left;

padding:22px;

padding-bottom:10px;

padding-top:0px;

list-style-type: none;

position:relative;

}

/* watch videoform when the video is clicked */

.watch-video-div{

position:absolute;

top:83px;

left:209px;

width:750px;

height:420px;

background-color:white;

border:0px solid grey;

border-radius:0px;

}

.watch-video{

position:relative;

border:0px solid #cce;

border-radius:px;

margin-left:-2px;

}

/* div for adding comment */

.add-comment{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:510px;

margin-left:209px;

width:748px;

border-radius:3px;

border:;

padding:1px;

}

.comment-profile-pic{

position:relative;

top:4px;

left:5px;

width:50px;

height:40px;

background-color:white;

border:1px solid grey;

border-radius:2px;

}

.add-comment-profile_photo{

position:absolute;

top:2px;

left:1px;

width:47px;

height:36px;

border-radius:2px;

}

.coment-form{

position:absolute;

top:6px;

left:61px;

width:367px;

height:36px;

border-radius:2px;

border:1px solid grey; }

.submit-comment{

position:absolute;

top:6px;

left:434px;

width:68px;

height:40px;

border-radius:3px;

border:1px solid grey;

}

.bookmark{

position:absolute;

top:6px;

left:509px;

width:68px;

height:40px;

border-radius:3px;

border:1px solid grey;

}

.count_view{

position:absolute;

top:6px;

left:583px;

width:85px;

height:40px;

border-radius:3px;

border:1px solid grey;

}

.comment-div{

position:absolute;

background-color:#dddddd;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:580px;

margin-left:210px;

width:748px;

border-radius:1px;

border:;}

.comment-horizontal-line{

color:white; }

.comment-user-name{

color:grey;

margin:-39px 0px 0px 61px;

font-size:15px;

position:absolute;

}

.comment-text{

color:black;

margin:-20px 0px 0px 60px;

font-size:15px;

position:absolute;

}

/* Begining of edit.php page styling */

.edit-video-container{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:85px;

margin-left:209px;

width:748px;

border-radius:3px;

border:;

padding:1px;

}

.edit-video{

position:relative;

top:8px;

left:5px;

border:0px solid grey;

width:590px;

}

.title-video{

position:absolute;

top:-7px;

left:169px;

border:1px solid grey;

width:320px;

height:25px;

}

.watermark{

top:23px;

left:169px;

width:320px;

height:70px;

color:#777;

background-color:#fff;

overflow: hidden;

border:1px solid black;

position:absolute;

}

.input {

border: 1px solid #A5C2C8;

color: #000000;

padding: 5px;

width: 480px;

}

.edit-button{

position:absolute;

background-color:#cce;

top:56px;

left:509px;

width:68px;

height:40px;

border-radius:3px;

border:1px solid #ccc;

color:grey;

}

.delete-button{

position:absolute;

background-color:#cce;

top:56px;

left:509px;

width:85px;

height:40px;

border-radius:3px;

border:1px solid #ccc;

color:grey;

}

.delete-button a{

text-decoration:none;

position:absolute;

top:10px;

margin-left:5px;

}

.home-video-title{

position:absolute;

left:9px;

}

/* Begining of bookmark.php page styling */

.bookmar-video{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:145px;

margin-left:210px;

width:885px;

border-radius:3px;

border:;

padding:1px;

}

.bookmark-header{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:83px;

margin-left:210px;

width:885px;

border-radius:3px;

border:;

padding:1px;

}

.bookmark-title{

position:relative;

margin-left:10px;

color:#cce;

}

/* Begining of edit_account.php page styling */

.edit-div-container{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:145px;

margin-left:210px;

width:885px;

border-radius:3px;

border:;

padding:1px;

}

.profile-photo-div{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:500px;

margin-left:210px;

width:885px;

border-radius:3px;

border:;

padding:1px;

}

.preview{

width:160px;

left:250px;

position:absolute;

height:160px;

}

#position_edit_form{

position:;

left:24px;

top:41px;

}

.edit_account_form

{

width:300px;

border-radius:3px;

border:1px solid #cce;

height:40px;

}

#submit_button

{

position:relative;

width:120px;

height:50px;

left:104px;

top:-9px;

border-radius:5px;

border:1px solid #cce;

background-color:#f4f8fb;

color:blue;

font-size:29px;

}

.view-video-div{

position:relative;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:85px;

margin-left:210px;

width:885px;

height:605px;

border-radius:3px;

border:;

padding:1px;

}

/* home page styling*/

.most-watch-video{

position:absolute;

top:-15px;

margin-left:32px;

font-size:12px;

color:red;

}\

.styling_post_like_link{

position:absolute;

top:0px;

left:680px;

border-radius:3px;

border:0px solid grey;

}

.styling_like_count{

position:absolute;

top:-13px;

left:708px;

border-radius:3px;

border:0px solid grey;

}

.styling_unlike_button{

position:absolute;

top:21px;

left:680px;

border-radius:3px;

border:0px solid grey;

font-size:11px;

}

.styling_unlike_count{

position:absolute;

top:3px;

left:718px;

border-radius:3px;

border:0px solid grey;

}

Chapter One (1)

Registration script

Chapter one is all about the registration process of any new users who want to upload or view videos on this video sharing social network. The new user must have to register or sign up before he or she can upload or view videos. This chapter one contains the registration and login form where the user can provide some details about he or her private information. Below is the registration form where the new user can sign up.

Create a file called index.php which contains the registration form. Below is the index.php page for registration.

Register to upload your videos













Male

Female

Born on

Day













Year





After creating the registration page above we need to create a file called exec.php which is indicated green above. This exec.php file above will insert all the sign up users’ details into the database.

<?php
session_start();
include(‘connection.php’);
$firstname=$_POST[‘firstname’];
$secondname=$_POST[‘secondname’];
$email=$_POST[‘email’];
$sex=$_POST[‘sex’];
$password=$_POST[‘password’];
$photo=$_POST[‘profile_picture’];
$day=$_POST[‘day’];
$month=$_POST[‘month’];
$year=$_POST[‘year’];
mysql_query(“INSERT INTO member(firstname, secondname, email, sex, password, profile_picture, day, month, year)
VALUES”);
header(“location: home.php”);
mysql_close($con);

?>

Next is to create a php page called home.php where the sign up or newly registered user will be taken to. This home.php page is the page that will show the user profile names, user profile photo, uploading videos, viewing videos, editing videos information, like and dislike videos, add comment to any videos and many more.

// include the below php script at the top of the in the home.php page

<?php

session_start();
include(“connection.php”);//connect to the database
include(“function.php”);//This is the include file above indicated above

?>


welcome to 23tutorials.com video social network learning script for newbie’s programmers.
Hopes you enjoyed this tutorial.
Follow the entire above video social network tutorials and you will benefit and learn new trick to create your own social network.Thanks

Chapter (2)

Login script

This is the login form where user can login and when they have finished their sign up process completely. We are still going to use the index.php page where but this time will are going to add only the login form. The user must login to have access to all activities happening on the social networks.

Below is the index.php page which contains the login form.

session_start();
//Unset the variables stored in session
unset($_SESSION['SESS_MEMBER_ID']);
unset($_SESSION['SESS_FIRST_NAME']);
unset($_SESSION['SESS_LAST_NAME']);
?>

Next is to create a php file called loginscript.php which will validate the information the user provide to login. This loginscript.php will check if the user already has an account on this video website and it ill checks if the user has provided wrong information to login.

//Start session
session_start();
//Include database connection details
require_once('connection.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if (get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$email = clean($_POST['login_email']);
$password = clean($_POST['login_password']);
//Input Validations
if ($email '') { $errmsg_arr[] = 'email missing'; $errflag = true; } if ($password '') {
$errmsg_arr[]= 'Password missing';
$errflag = true;
}
//If there are input validations, redirect back to the login form
if ($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
//Create query
$qry="SELECT * FROM member WHERE email='$email' AND password='$password' ";
$result=mysql_query($qry);
//Check whether the query was successful or not
if ($result) {
if (mysql_num_rows($result) > 0) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION[‘SESS_MEMBER_ID’] = $member[‘member_id’];
$_SESSION[‘SESS_FIRST_NAME’] = $member[‘email’];
$_SESSION[‘SESS_LAST_NAME’] = $member[‘password’];
session_write_close();
header(“location: home.php”);
exit();
} else {
//Login failed
$errmsg_arr[] = ‘email and password not found’;
$errflag = true;
if ($errflag) {
$_SESSION[‘ERRMSG_ARR’] = $errmsg_arr;
session_write_close();
header(“location: index.php”);
exit();
}
}
} else {
die(“Query failed”);
}
?>

Next is the home.php page where when the user has sign up or login, it will take him into the home.php page where he can upload profile photo, upload videos, add comments related to video, watch video, bookmark video. plesae take note that the home.php page will be used throughout the upcoming steps in this tutorial.

 

//Below is the home page that the login user will be taken after login process is completed.

// include the below php script at the top of the in the home.php page

session_start();
include("connection.php");//connect to the database
include("function.php");//This is the include file above indicated above
?>

 


welcome to 23tutorials.com social network learning script for newbie’s programmers.
Hopes you enjoyed this tutorial.
Follow the entire above video social network tutorials and you will benefit and learn new trick to create your own social network. Thanks

Chapter (3)

How to upload video script

After when the user has login successfully, he or she can upload video that can be or will be view by everyone on the video social network. We are using the home.php page mention above where only the login user can upload and view videos.

Below is the database that will store the uploaded videos.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

Next is the home.php page contains the video uploading form.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

//below is the Jquery files, please use the one that you have or visit www.23tutorials.com and get it for free.

//below is another Jquery file, please use the one that you have or visit www.23tutorials.com and get it for free

+

Add Images

Next is the php file call “videoupload.php” indicated above which will validate and store the login user uploaded video into the database.

<?php

session_start();

include(“connection.php”); // connect to the database

include(“function.php”);

$member_id= $_SESSION[“logged”];

$firstname= $_firstname;

$secondname = $_secondname;

$path = “videos/”; // please create a folder called videos for keeping the uploaded videos

$video_formats = array(“mp4”);

$valid_formats = array(“mp4”, “flv”, “avi”, “wmv” , “mpg”);

if(isset($_POST) and $_SERVER[‘REQUEST_METHOD’] == “POST”)

{

$photo_name = $_FILES[‘photoname’][‘name’];

$size = $_FILES[‘photoname’][‘size’];

if (strlen($photo_name))

{

list($txt, $ext) = explode(“.”, $photo_name);

if(in_array($ext,$video_formats))

{ if($size<(1000000*1000000))

{ $video_name = $_FILES[‘photoname’][‘name’];

$tmp = $_FILES[‘photoname’][‘tmp_name’];

if(move_uploaded_file($tmp, $path.$video_name))

{

mysql_query(“INSERT INTO video_upload(member_id, firstname, secondname, raw_video_title, video_title, date)

VALUES )”);

//echo ““;

echo “

“;

}

else

echo “failed”;

}

else

echo “video file size max 10000 MB”;

}

else

echo “Incorrect VIDEO format..”;

}

else

echo “Choose a video please..!”;

exit;

}

?>

Chapter (4)

How login user can view his all uploaded videos script

This is the view video script where login user can view all the uploaded videos and he / she can choose which video to watch.

Below is the database where all the user uploaded videos will be stored.

Below is the database for the storing all the uploaded videos and where we are going to select the login user uploading videos he want to see.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

Next create a page called home.php after when you are done with the login and signup steps in the tutorials which will contain the video uploading form.
p. Below is the home.php where the login user can upload videos and share it. Remember that this home.php will be used throughout this tutorial as from now.

 

 

 

 

 

 

 

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

<?php

$member_id =$_SESSION[“logged”];

$result= mysql_query(“select * FROM `video_upload` LIMIT 6 “);

while($row=mysql_fetch_array($result))

{

echo’

    ‘;

    echo’

  • ‘;

    echo”

    “.$row[‘video_title’].”

    “;

    echo’

  • ‘;

    echo’

‘;

}

?>

Chapter (5)

How to watch videos script

This is the watch video script where the login user can watch any uploaded videos he / she clicks in order to watch it. We are going to use two pages the first is the home.php page and the second will be watch_video.php page.

Below is the database where all the uploaded videos will be stored.

Below is the database for the storing all the uploaded videos and where we are going to select the video we want to see.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

Next create a page called home.php after when you are done with the login and signup steps in the tutorials which will contain the video uploading form.

Below is the home.php where the login user can view and click any videos he / she want to watch. This videos have a link (watch_video.php) which will take the user to a page called watch_video.php where he can watch the video.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

<?php

$member_id=$_SESSION[“logged”];

$result= mysql_query(“select * FROM `video_upload` LIMIT 6 “);

while($row=mysql_fetch_array($result))

{

echo’

    ‘;

    echo’

  • ‘;

    echo”

    //when the user clicks the link of the video below it will take him to the page watch_video.php where he can watch the video.

    “.$row[‘video_title’].”

    “;

    echo’

  • ‘;

    echo’

‘;

}

?>

Next is the php page called “watch_video.php” where the user can watch the video he clicks from the home.php page above.

 

<?php
session_start();

include (“connection.php”); // connect to the database

include (“function.php”);

$video_id = $_GET[“video_id”];
?>

<?php

$result= mysql_query(“select * FROM `video_upload` WHERE video_id=’$video_id’”);

while($row=mysql_fetch_array($result))

{

echo”

“;

}

?>

Chapter (6)

Uploading profile picture script

This is the change profile photo script where the login user can change his profile photo.

Below is the database for the storing the uploaded profile photo.

CREATE TABLE IF NOT EXISTS `member` (
`member_id`int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(30) NOT NULL,
`secondname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`sex` varchar(100) NOT NULL,
`password` varchar(30) NOT NULL,
`profile_picture` varchar(30) NOT NULL,
`day` varchar(100) NOT NULL,
`month` varchar(30) NOT NULL,
`year` varchar(100) NOT NULL,
PRIMARY KEY (`member_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

 

Next create a page called home.php that contains the form for uploading profile picture.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

+

Add Images

Upload your image

 

 

 

Next is the php file called “upload_photo.php” which will insert the updated profile photo into the database?

<?php

session_start();

include(“connection.php”); // connect to the database

include(“function.php”);

$member_id= $_SESSION[“logged”];

$path = “uploads/”; // uploads is the folder for storing the uploaded profile photo.

$photo_formats = array(“jpg”, “png”, “gif”, “bmp” , “PNG” , “JPG”, “GIF”);

if(isset($_POST) and $_SERVER[‘REQUEST_METHOD’] == “POST”)

{

$photo_name = $_FILES[‘photoname’][‘name’];

$size = $_FILES[‘photoname’][‘size’];

if(strlen($photo_name))

{

list($txt, $ext) = explode(“.”, $photo_name);

if(in_array($ext,$photo_formats))

{

if($size<(9000*9000))

{

$image_name = time().substr(str_replace(” “, “_”, $txt), 5).”.”.$ext;

$tmp = $_FILES[‘photoname’][‘tmp_name’];

if(move_uploaded_file($tmp, $path.$image_name))

{

mysql_query(“UPDATE member SET profile_picture=’$image_name’ WHERE member_id=’$member_id’”);

echo ““;

}

else

echo “failed”;

}

else

echo “Image file size max 9 MB”;

}

else

echo “Incorrect image format..”;

}

else

echo “Choose an image..!”;

exit;

}

?>

Chapter (7)

Show user profile name / photo script

This is the view profile names and photo script where the login user can view his profile names and photo.

Below is the database for the storing the uploaded profile names and photo.

CREATE TABLE IF NOT EXISTS `member` (
`member_id`int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(30) NOT NULL,
`secondname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`sex` varchar(100) NOT NULL,
`password` varchar(30) NOT NULL,
`profile_picture` varchar(30) NOT NULL,
`day` varchar(100) NOT NULL,
`month` varchar(30) NOT NULL,
`year` varchar(100) NOT NULL,
PRIMARY KEY (`member_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Next create a page called home.php that shows the profile names and picture.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

<?php

/* select the names of the login from the database */

$member_id =$_SESSION[“logged”];

$result = mysql_query(“SELECT * FROM `member` WHERE `member_id`=’$member_id’ LIMIT 1”);

echo “

“;

while($row = mysql_fetch_array($result))

{

echo “

“;

echo ““;

echo “

“;

echo “

“;

}

echo “

“ . $row[‘firstname’] .’ ‘. $row[‘secondname’] . “
“;

?>

Chapter (8)

How to search video script

This is the search engine script where the login user can search for any videos he likes in Jquery.

Below is the database for the storing the videos that will be searched.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

Next create a page called home.php which contains the search engine form and it shows the search result.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

Next is the php file call “search.php” which search for the videos in the database.

 

<?php

include(‘connection.php’);

if ($_POST)

{

$query = $_POST[‘search’];

$sql = mysql_query(“SELECT * FROM `video_upload` WHERE `video_title` LIKE$query

UNION

SELECT * FROM `video_upload` WHERE `description` LIKE$queryLIMIT 15 “) or die (mysql_error());

$num_of_row = mysql_num_rows($sql);

if ($num_of_row > 0 ) {

while($row = mysql_fetch_array($sql))

{

$id = $row[‘video_id’];

$description = $row[‘description’];

if ($description!=’‘)

{

echo “

“. $row[‘description’].” “;

echo “


“;

}else{

echo “

“.$row[‘video_title’].”“;

echo “


“;

}

}

}

else

{

echo “No result found!“;

}

}

?>

Chapter 8: How to edit video information script

YouTube edit videos information in database. Welcome to our tutorial we hope you enjoy it

This is the edit video information script where the login user can edit or change his uploaded video information.

Below is the database for editing the videos information in the database.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Next create a page called home.php which conains the login user’s videos to be edited.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

<?php

$result = mysql_query(“select * FROM `video_upload` WHERE member_id=’$member_id’ LIMIT 5”);

while($row=mysql_fetch_array($result))

{

echo “


“;

}

?>

Next is the php file called “video_description.php” to insert the video edit information into the in the database.

<?php

session_start();

include(“connection.php”);

include(“function.php”);

$my_id = $_SESSION[“logged”];

$video_title = $_POST[‘videoe_title’];

$video_desscription = $_POST[‘description_text’];

$video_id = $_POST[‘video_id’];

mysql_query(“UPDATE video_upload SET video_title=’$video_title’,description=’$video_desscription’ WHERE video_id=’$video_id’”) or

die(mysql_error());

{

echo ““;

}

?>

Chapter (9)

How delete video script

This is the edit video information script where the login user can edit or change his uploaded video information.

Below is the database for editing the videos information in the database.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

Next create a page called home.php which contains the login user’s videos to be edited.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

<?php

$result= mysql_query(“select * FROM `video_upload` WHERE member_id=’$member_id’ LIMIT 5”);

while($row=mysql_fetch_array($result))

{

echo “

<input type=‘text’ name=‘videoe_title’ value=’”.$row[‘video_title’].”’ class=‘title-video’ placeholder=‘Title of the video’ title=‘Please give a title of your video


“;

}

?>

Next is the php file called “delete_upload_video.php” above to delete the login user video into the in the database.

 

<?php

session_start();

include(“connection.php”); // connect to the database

include(“function.php”); //get the id (member_id) for the login user

?>

<?php

$myfriend = $_GET[‘delete’];

$me = $_SESSION[“logged”];

$query = mysql_query(“delete from video_upload WHERE member_id = ‘” . $_SESSION[“logged”] . “’ AND video_id = ‘” . $_GET[‘delete’] . “’ “);

{

echo ““;

}

?>

Chapter: (10)

How to add comment to a video script

This is the add comment on video script where the login user can add comment that is related to the video that the user is watching.

Below is the database where all the user uploaded videos will be stored.

Below is the database for the storing all the uploaded videos and where we are going to select the video we want to see.

CREATE TABLE IF NOT EXISTS `video_upload` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` varchar(100) NOT NULL,
`firstname` varchar(100) NOT NULL,
`secondname` varchar(30) NOT NULL,
`raw_video_title` varchar(1000) NOT NULL,
`video_title` varchar(1000) NOT NULL,
`description` varchar(100) NOT NULL,
`date` varchar(30) NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;

Below is the database for storing the comment that is related to a video database.

CREATE TABLE IF NOT EXISTS `video_comment` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`video_id` int(11) NOT NULL,
`memberid` int(11) NOT NULL,
`date` date NOT NULL,
`comment` varchar(5000) NOT NULL,
PRIMARY KEY (`comment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

Next create a page called home.php aftre when you are done with the login and signup steps in the tutorials which will contain the video uploading form.

Below is the home.php where the login user can view and click any videos he / she want to watch. These videos have a link (watch_video.php) watch will take the user to a page called watch_video.php where he can watch the video.

session_start();
include ("connection.php"); // connect to the database
include("function.php");
?>

<?php

$member_id = $_SESSION[“logged”];

$result = mysql_query(“select * FROM `video_upload` LIMIT 6 “);

while($row=mysql_fetch_array($result))

{

echo’

    ‘;

    echo’

  • ‘;

    echo”


    //below is the link that will take the user to the page where he will add comment to the video he is watching.

    “.$row[‘video_title’].”

    “;

    echo’

  • ‘;

    echo’

‘;

}

?>


Next is the php file called “watch_video.php” as indicated above where the user can watch the video he clicks from the home.php page above.

 

session_start();
include ("connection.php"); // connect to the database
include ("function.php");
$video_id = $_GET["video_id"]; // the id of the video that has been click.
?>

<?php

/* profile photo of user who commented */

$member_id=$_SESSION[“logged”];

$result = mysql_query(“SELECT * FROM `member` WHERE `member_id`=’$member_id’ LIMIT 1”);

while($row = mysql_fetch_array($result))

{

echo ““;

echo ““;

echo ““;

}

echo ““;

?>

<?php

/* add comment onto video */

echo”

“;

?>


youtube tutorial youtube tutorial