Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.