Hey guys.
Does anyone have any scripts or tuts that show how to make a php portal.
For Example.
Lets say I want to Host Video Streaming, but don't want to make a html page for every clip.
How would I create a .php [eg view.php]
to become something like view.php?video-id=12345
and brings up a page, that plays that video file with the Id 12345.
Thanks In Advance!
| Code: |
<?PHP
echo $_GET['video-id'];
?> |
If you run this script with ?video-id=test, it would output "test". No big deal. 
| Ducksteina wrote: |
| Code: | <?PHP
echo $_GET['video-id'];
?> |
If you run this script with ?video-id=test, it would output "test". No big deal.  |
If you don't understand, if you do this and output the video-id inside an html tag to display a video (where the id would go normally), this will play the video.
You can make html page and use php only for pages you need. For example for displaying list of videos and selecting one. Just try play with that :
| Code: |
//put thath code to .php file and try to run
<html>
<body>
<?php
if ($_REQUEST["video-id"]){ //check if video sellected
$videoNo=$_REQUEST['video-id']; //getting selected video number
echo "Starting to play video $videoNo. Here you can put html code to play video file with requested id ";
}else{
//output all aviable video links
echo '
<a href="?video-id=1">Play video No. 1</a><br>
<a href="?video-id=2">Play video No. 2</a><br>
<a href="?video-id=3">Play video No. 3</a><br>
<a href="?video-id=4">Play video No. 4</a><br>
You can generate all links automaticaly';
}
?>
</body>
</html> |
Its more usefull to have information on videos in database, so you can easily generate list with links to videos with additional information.
do you need it in the URL?
you could use a <form method='POST'><select>
with a dynamically generated foreach ("<option><?php $each ?></option>")
getting the values out of an mySQL database.
(can you understand that?)
hey guys.
thanks for all ur info.
How would i make a php that has embeded video/audio play
*im guessing:
| Code: |
<?php
if($_REQUEST["video-id"]) {
$videoid=$_REQUEST["video-id"];
echo ('<OBJECT
ID="mediaPlayer"
CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
STANDBY="Loading Microsoft Windows Media Player components..."
TYPE="application/x-oleobject">
<PARAM NAME="fileName" VALUE="<?php $videoid ?>"> [b] //This part is obviously not valid...how do u make it a file.
[/b]<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="true">
<PARAM NAME="showControls" VALUE="true">
</OBJECT>');
<a href="video/download/<?php $videoid?>"> Download File </a> // This will call up the 'download file' link.
} else {
include('index.php'); //I want it to show the main page if nothing has been selected
}
?>
|
Now how would i call up the file?
without using MySql. Should i use eg: 'include('video-id.php [or .txt]);'
If i wanted more info, such as Downloads, Author, File Size, file type etc...
Would it require a DB?
Thanks Guys.
| moejoe wrote: |
hey guys.
thanks for all ur info.
How would i make a php that has embeded video/audio play
*im guessing:
| Code: |
<?php
if($_REQUEST["video-id"]) {
$videoid=$_REQUEST["video-id"];
echo ('<OBJECT
ID="mediaPlayer"
CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
STANDBY="Loading Microsoft Windows Media Player components..."
TYPE="application/x-oleobject">
<PARAM NAME="fileName" VALUE="<?php $videoid ?>"> [b] //This part is obviously not valid...how do u make it a file.
[/b]<PARAM NAME="animationatStart" VALUE="true">
<PARAM NAME="transparentatStart" VALUE="true">
<PARAM NAME="autoStart" VALUE="true">
<PARAM NAME="showControls" VALUE="true">
</OBJECT>');
<a href="video/download/<?php $videoid?>"> Download File </a> // This will call up the 'download file' link.
} else {
include('index.php'); //I want it to show the main page if nothing has been selected
}
?>
|
Now how would i call up the file?
without using MySql. Should i use eg: 'include('video-id.php [or .txt]);'
If i wanted more info, such as Downloads, Author, File Size, file type etc...
Would it require a DB?
Thanks Guys. |
| Code: |
| <param name="fileName" value="' . $videoid . '.ext"> |
Something like this, replace ext with whatever your video is called, for example if it's called 1145.swf, use .swf instead of .ext
And if you want additional information you'll need a database, or some database text file.
Thanks for that it worked [came up as 1.mpg]
How would the .php recognise the video-id for the file tho?
If you get what i mean.
Like...If the Video-id is 1...how would the php know to execute
video1.mpg? or do i have to call everything by it's number[eg. 1.mpg]?
It would be easier that why wouldn't it...
About the Database.
How to i begin..
I know how to set it up...but all these tuts are so confusing.
If i wanted to make a basic portal like the one i was discribing [eg. hits, filetype, author all of that] how would i put that onto MySQL?
Thanks for all your help!
| moejoe wrote: |
Thanks for that it worked [came up as 1.mpg]
How would the .php recognise the video-id for the file tho?
If you get what i mean.
Like...If the Video-id is 1...how would the php know to execute
video1.mpg? or do i have to call everything by it's number[eg. 1.mpg]?
|
If you do
| Code: |
| <param name="fileName" value="video' . $videoid . '.ext"> |
It will load video1.mpg for 1, if you want it to load anexamplevideo.mpg for 1 and anothervideo.mpg for 2, you need a database.
| Quote: |
It would be easier that why wouldn't it...
About the Database.
How to i begin..
I know how to set it up...but all these tuts are so confusing.
If i wanted to make a basic portal like the one i was discribing [eg. hits, filetype, author all of that] how would i put that onto MySQL?
Thanks for all your help! |
One table, with columns hits, filetype, author, title, and so on
With phpMyAdmin
Cool Thanks.
Does anyone have a real indepth Tutorial on Creating a MySQL db.
I've learnt the basics, like creating tables writing, reading ect...
I just need to learn more!!
Any Links Would be very helpful and a BIG thanks to all you guys!
Oh, and How would i effectively upload this info?? Should i make a .php that'll upload info to my db? or should i do it manually thru myphpadmin {if thats possible}.
Thanks again!
Cheers!
Hey Guys!
check out my final product.
http://www.unlockit.frih.net/mobilefun/videos/video.php?id=1
Pretty Sweet Huh?
See how it says: Downloads: not Avalible..
yer well there i'd like to add a hit counter...
I was thinking along the lines of on the Download File Link make a download.php and run it along side the 'id' in my DB.
So i'll do all the MySQL stuff
and add
| Code: |
// My Download.php Script
//keep in mind this is after i do all that MySQL CR*P
<?php
$up_downloads = $downloads++1; //Don't Know..Is this valid?
$query = UPDATE data SET downloads ='$up_downloads' WHERE id = '$id' //This Script will update the $id with +1 more download on the INT
mysql_query($query) or die("Sever Busy. Try Again Later"); //Have to keep it user friendly =)
mysql_close();
header("Location: ' .$download_dir. '"); //This will download the file.
?> |
If you find any errors in that, please post it.
wow i cant believe i made that out of scratch.
Thanks Again!
Last edited by moejoe on Thu Apr 27, 2006 12:02 pm; edited 1 time in total
| moejoe wrote: |
Hey Guys!
check out my final product.
http://www.unlockit.frih.net/mobilefun/videos/video.php?id=2
Pretty Sweet Huh?
See how it says: Downloads: not Avalible..
yer well there i'd like to add a hit counter...
I was thinking along the lines of on the Download File Link make a download.php and run it along side the 'id' in my DB.
So i'll do all the MySQL stuff
and add
| Code: |
// My Download.php Script
//keep in mind this is after i do all that MySQL CR*P
<?php
$up_downloads = $downloads++1; //Don't Know..Is this valid?
$query = UPDATE data SET downloads ='$up_downloads' WHERE id = '$id' //This Script will update the $id with +1 more download on the INT
mysql_query($query) or die("Sever Busy. Try Again Later"); //Have to keep it user friendly =)
mysql_close();
header("Location: ' .$download_dir. '"); //This will download the file.
?> |
If you find any errors in that, please post it.
wow i cant believe i made that out of scratch.
Thanks Again! |
Mostly valid I think, only:
$up_downloads = $downloads+1;
one plus is enough
$query = "...";
You forgot your quotes around the query.
But I think you can add the download in SQL instead of in PHP:
| Code: |
| $query = "UPDATE `data` SET `downloads` = `downloads` + 1 WHERE `id` = '" . $id . "'"; |
you can use a similar code to this to upload your own data to the database through a php script rather than phpMyAdmin.
say that you had these as your column names:
video_ID
video_name
video_author
etc.
im not going into normalising the database as it should be done when creating databases.
the code is as follows:
| Code: |
<?php
if(isset($_POST['submit']))
{
//variables
$videoName = $_POST['videoName'];
$videoAuthor = $_POST['videoAuthor'];
$videoSize = $_POST['videoSize'];
//login details for connection to mySQL database
$user = 'username'; //change this to your username
$pass = 'password'; //change this to your password
$host = 'localhost'; //this can stay the same if its on the same server
$db = 'table_name'; //change this to the name of your table
//connect to database
mysql_connect($host, $user, $pass)
or die('Failed to connect to database. <br>Error: '.mysql_error());
//select the database
mysql_select_db($db)
or die('Failed to select the database. <br>Error: '.mysql_error());
//query to insert data into database
$insertData = "INSERT INTO table_name VALUES('$videoName', '$videoAuthor', '$videoSize')"; //change or add values but remeber to change the variables at the top to match so it will get the information from the form
//run the query that was just created
mysql_query($insertData);
}
?>
<form name="form1" method="post" action="">
<p>Video Name:
<input name="videoName" type="text" id="videoName">
</p>
<p>Video Author:
<input name="videoAuthor" type="text" id="videoAuthor">
</p>
<p>
Video Size:
<input name="videoSize" type="text" id="videoSize">
</p>
<p>
<input name="submit" type="submit" id="submit" value="Submit">
</p>
</form>
|
This code has not been checked but if you have any problems after you have changed the parts that requires changing post a reply and ill see how i can help
Hey,
Thanks for your speedy Replies
I tried the .php script, but i found the Phpadmin better because it'd tell me all the error details and would translate the script into php so i could use it also.
I'll Give it a go later, right now i gotta get some rest!
how funny is that clip! hehe.
Wow this MySql stuff is really, really easy! I can make my own search engine from this too
Oh, and, Lets say i want to make a 'Most recently added' thingy onto my website. I use this:
| Code: |
SELECT * FROM `data` ORDER BY `date` ASC
|
How do i get the top 5 out of that? Is it LIMIT 0,5?
Thanks!
| moejoe wrote: |
Hey,
Thanks for your speedy Replies
I tried the .php script, but i found the Phpadmin better because it'd tell me all the error details and would translate the script into php so i could use it also.
I'll Give it a go later, right now i gotta get some rest!
how funny is that clip! hehe.
Wow this MySql stuff is really, really easy! I can make my own search engine from this too
Oh, and, Lets say i want to make a 'Most recently added' thingy onto my website. I use this:
| Code: | SELECT * FROM `data` ORDER BY `date` ASC
|
How do i get the top 5 out of that? Is it LIMIT 0,5?
Thanks! |
ORDER BY `Date` DESC
ASC means from lowest value to highest value
DESC means from highest value to lowest value
So ASC would get the first 5 instead of the latest 5.
I always use LIMIT 5 and it seems to work, but I think LIMIT 0,5 should work too.
the limit 0,5 will work
the first number is where you want it to start and the second number is how many after your starting point you want it to show
Cool Thanks..
Just as a Tip..
Remember to Put the Header() Output BEFORE the <body> tag..
I had alot of difficulties with that damn header() output.
I Got some more Questions to Ask To...I hope you all dnt mind.
>> How do I make a multipage Search. So Lets say After 20 Search Query's it'll stop and create another page automatically.
>>How do you change the <Title> with PHP so it comes up with a dynamic title. <title><?php echo '$title'; ?></title> don't work..what will?
Thanks All My Questions...
For Now..
Thanks for all your help!
| moejoe wrote: |
| >>How do you change the <Title> with PHP so it comes up with a dynamic title. <title><?php echo '$title'; ?></title> don't work..what will? |
| Code: |
| <title><?php echo $title; ?></title> |
will
i don't know exactly how you can have multiple pages but you will need something like this to know where to start for your LIMIT query.
| Code: |
$limit = 0;
if(isset($_POST['next20']))
{
$limit += 20;
}
mysql_query("SELECT * FROM `data` ORDER BY `date` DESC LIMIT $limit,20");
|
this code needs touching up as the $limit = 0 will always set back to 0 and this will need to update.
Im sure someone can improve it and then it will also help me out too.
Well,
I need to work out something.
How Would I make lets say a index.php that'll read my MySQL and write all the data onto seperate rows.
So The Rows colums with include
|| ID | TITLE | DOWNLOADS | DATE ||...
You'll have to Exicute this:
$rows = mysql_countrows()
How would I place $rows into a HTML to make a table? is there a better way?
How would i limit the number of results per page and then create another page automatically so it'll come out like > index.php?page=2
Thanks for your help in advance!
hi.
i have a website just for my class-mates.
this website is just an alumni website.
i want only them to login and view the information.
i want only 50 user id and password for my website.
can any one tell me how to do that.
plz note that other should not see inside my website and my friends can change only their profile.
i am posting it 2nd time for more views.
plz help me.
regards
Deepak Chopra