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.