<?php
require_once("connect.php");
global $ok;
if(isset($_POST["install"])){
$Conn->create_db("videos");
$Conn->select_db("videos");
$table = array("TABLE" => "youtube",
"id" => "INTEGER AUTO_INCREMENT PRIMARY KEY",
"videoID" => "VARCHAR(40)",
"name" => "VARCHAR(200)",
"comments" => "VARCHAR(600)",
"rate" => "VARCHAR(20)");
$Conn->create_table($table);
if($Conn->db_exists("videos")==true AND $Conn->table_exists("youtube")){
echo "<script>alert('Database and table sucessfuly created !')</script>";
$self = $_SERVER['PHP_SELF'];
$step2 = "<h5>TABLE WERE SUCCESSFULY CREATED</h5>";
$step2 .= "<p</p>";
$step2 .= "<strong>Press 'Insert' to add some example data</strong>";
$step2 .= '<hr>';
$step2 .= '<form action="'.$self.'" method="post" >';
$step2 .= '<input type="submit" name="insert" value="Insert">';
$step2 .= '</form>';
print $step2;
}else{
echo "<script>alert('Opss !!! Error on creating database or table !')</script>";
}
exit();
}
if(isset($_POST["insert"]) OR isset($_GET["tag"])=="show"){
require_once("insert_videos.php");
$rs = mysql_query("SELECT * FROM youtube");
$num = mysql_num_rows($rs);
if($num==0){
ob_start(); // correction #ref 001
require_once("load_videos.php");
if($Video->addVideos($arr)){
$ok=true;
}
ob_end_clean(); // correction #ref 002
if($ok==true){
echo "<h3>Some videos are now available </h3>";
echo "Click <a href='load_videos.php' target='_self'>here</a> to see videos on database";
}else{
$ok = false;
echo "There occurred an error inserting your data";
}
}elseif($num > 0){
$ok = true;
echo "<h3>Table already exists </h3>";
echo "Click <a href='load_videos.php' target='_self'>here</a> to see videos on database";
}
exit();
}
?>
<strong>Press 'Install' to create database and tables of the system</strong>
<hr>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >
<input type="submit" name="install" value="Install">
</form>
|