Haruo Posted August 8, 2009 Share Posted August 8, 2009 Hello, I need some help. I am trying to make a video streaming site but I know barly anything about PHP all I no is the extream basics. Okay what I need is a PHP form which can add information into the database information like. Title: <-- Video Title --> Description: <!-- Video Description 200 charecter max --> Tags: <!-- Video Tags --> Rating: <!-- Drop Down Options: Everyone, Teenagers, Mature, Adult --> Video URL: <!-- FLV Location --> Added By: <!-- Name Input --> Added Date: <!-- Ads Date added to datbase by it self --> Okay now when this video is added to the database the script makes a random string so the when member goes to the index.php page and clicks the video he wants the video will load under /v?=GH56DA something like MegaVideo uses. I know how to use echo to show all results, I now a bit how to use select script which will fetch this from datbase. All I need help with is a form that will add the info to the database and a script in the submision form that will make a random video string like GH56DA from which the video can be called from /v?=GH56DA -Thank You! Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/ Share on other sites More sharing options...
trq Posted August 8, 2009 Share Posted August 8, 2009 Theres a link in my signature (Hudzilla) to a free book. This book has a chapter on using forms with php and another about using databases. Reading them you should have all the information you need. Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-893404 Share on other sites More sharing options...
Haruo Posted August 9, 2009 Author Share Posted August 9, 2009 That did not help. I can try to code the code but I dont understand how to make a random key for each video. Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-894250 Share on other sites More sharing options...
wildteen88 Posted August 9, 2009 Share Posted August 9, 2009 Had a quick google search Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-894251 Share on other sites More sharing options...
Haruo Posted August 9, 2009 Author Share Posted August 9, 2009 <?php $con = mysql_connect("localhost", "******_root", "********"); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****_yoko", $con); $sql="INSERT INTO doVideos (title, plot, tags, rating, video) VALUES ('.$title.','.$plot.','.$tags.','.$rating.','.$video.')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Information has been added"; mysql_close($con) ?> Here is a code that I made to add videos to MySQL table doVideos. But I still dont get the part of how to add random key like XRFH1ZL -Edited: And here is one more version of the code to add videos. <?php require_once 'db.php'; $task = isset($_POST['task']) ? $_POST['task'] : ''; $error_string = ''; if ($task == 'video.add') { $title = trim($_POST['title']); //trim to remove whitespace $episode = trim($_POST['episode']); //trim to remove whitespace $tags = trim($_POST['tags']); //trim to remove whitespace $descr = trim($_POST['descr']); //trim to remove whitespace $video = trim($_POST['video']); //trim to remove if (!isValidTitle($video)) $error_string .= 'Plase enter a video utl.<br>'; if ($episode == '') $error_string .= 'Please enter a episode #.<br>'; if ($tags == '') $error_string .= 'Please enter video tags.<br>'; if ($descr == '') $error_string .= 'Please enter a description.<br>'; if ($title == '') $error_string .= 'Please enter a title.<br>'; if ($error_string == '') { $result = db_query("SELECT id FROM doVideos WHERE video='" . mysql_real_escape_string($video) . "'"); if (mysql_num_rows($result) > 0) $error_string .= 'The video you supplyed already exists.<br>'; else { $title = mysql_real_escape_string($title); // protect against SQL attacks $episode = mysql_real_escape_string($episode); $tags = mysql_real_escape_string($tags); $descr = mysql_real_escape_string($descr); $video = mysql_real_escape_string($video); db_query("INSERT INTO doVideo (title, episode, tags, descr, video) VALUES ('{$title}', '{$episode}', '{$tags}', '{$descr}', '{$video}')"); header('Location: thankyou.php'); exit(); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Register</title> <style type="text/css"> .error_text { color: #FF0000; width: 400px; text-align: center; } .left_box { float: left; width: 150px; text-align: right; padding-right: 5px; } .right_box { clear: right; } </style> </head> <body> <div class="error_text"><?php echo $error_string; ?></div> <form action="video.php" method="post"> <input type="hidden" name="task" value="video.add"> <div class="left_box">Title:</div> <div class="right_box"><input type="text" name="title" size="30" maxlength="255" value="<?php if (isset($title)) echo $title; ?>"></div> <div class="left_box">Episode:</div> <div class="right_box"><input type="text" name="episode" size="30" maxlength="3" value="<?php if (isset($episode)) echo $episode; ?>"></div> <div class="left_box">Tags:</div> <div class="right_box"><input type="text" name="tags" size="30"></div> <div class="left_box">Deskription:</div> <div class="right_box"><input type="text" name="descr" size="30"></div> <div class="left_box">Video:</div> <div class="right_box"><input type="text" name="video" size="30"></div> <div class="left_box"> </div> <div class="right_box"><input type="submit" value="Add Video" size="30"></div> </form> </body> </html> For some reason for that code I get unexpected $end at line 97, and line 97 dosent even exist. Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-894254 Share on other sites More sharing options...
wildteen88 Posted August 9, 2009 Share Posted August 9, 2009 That error is usually caused due to your braces { and } not matching up. You need to check your code to see if they match up. Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-894269 Share on other sites More sharing options...
Haruo Posted August 9, 2009 Author Share Posted August 9, 2009 I can seem to find anything wrong with the code i checked it few times and still nothing Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-894270 Share on other sites More sharing options...
mattal999 Posted August 9, 2009 Share Posted August 9, 2009 You need an extra } at the end of the PHP section. You only have two there when there should be three. Link to comment https://forums.phpfreaks.com/topic/169303-how-to-do-this/#findComment-894272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.