0

Hello all, First I would like to say thank you to anyone helping, it is very much apperciated.

I'm trying to create a database of all of my movies(I know there are programs that do this but I would like to make my own)
So far I have created a database with xammp and a form to insert information into that database (I think it's working right)

I would like for the sumbit button of my form to create a new page that lists all of the form information, I would like to have a template for this page and place holders for where all the information will go, however I don't know how I should go about doing this, I've been searching for atleast 5 hours trying to find tutorials but with no luck.

Here is everything I have so far

My database http://i.imgur.com/14DQTCh.jpg

index.html

<html>
<head><title>Add Movie or Tv show</title></head>
<body>

<form enctype="multipart/form-data" id="myForm" action="addedinfo.php" method="post">
<h1 align="center"><strong>Add Movie or TV Show to Database</strong></h1>
<p>&nbsp;</p>
<p>Movie Name:
  <input type="text" name="Movie_Name" /><br />
</p>
<p><label> Poster</label>
          <input type="FILE" name="Poster"> <br>
  </p>
<p>Genre:
  <select multiple name="Genre[]" id="Genre">
    <option value="All" style="text-indent: 0px;" selected="selected">All</option>
    <option value="Action" style="text-indent: 0px;">Action</option>
    <option value="Adventure" style="text-indent: 0px;">Adventure</option>
    <option value="Animation" style="text-indent: 0px;">Animation</option>
    <option value="Biography" style="text-indent: 0px;">Biography</option>
    <option value="Comedy" style="text-indent: 0px;">Comedy</option>
    <option value="Crime" style="text-indent: 0px;">Crime</option>
    <option value="Documentary" style="text-indent: 0px;">Documentary</option>
    <option value="Drama" style="text-indent: 0px;">Drama</option>
    <option value="Family" style="text-indent: 0px;">Family</option>
    <option value="Fantasy" style="text-indent: 0px;">Fantasy</option>
    <option value="Film-Noir" style="text-indent: 0px;">Film-Noir</option>
    <option value="History" style="text-indent: 0px;">History</option>
    <option value="Horror" style="text-indent: 0px;">Horror</option>
    <option value="Mystery" style="text-indent: 0px;">Mystery</option>
    <option value="Romance" style="text-indent: 0px;">Romance</option>
    <option value="Sci-Fi" style="text-indent: 0px;">Sci-Fi</option>
    <option value="Short" style="text-indent: 0px;">Short</option>
    <option value="Sport" style="text-indent: 0px;">Sport</option>
    <option value="Thriller" style="text-indent: 0px;">Thriller</option>
    <option value="War" style="text-indent: 0px;">War</option>
    <option value="Western" style="text-indent: 0px;">Western</option>
  </select>
</p>
<p>
  <label>IMDB Rating:</label>
  <select name="IMDB_Rating" id="IMDB_Rating">
    <option value="0" style="text-indent: 0px;" selected="selected">All</option>
    <option value="9.9" style="text-indent: 0px;">10</option>
    <option value="9" style="text-indent: 0px;">9+</option>
    <option value="8" style="text-indent: 0px;">8+</option>
    <option value="7" style="text-indent: 0px;">7+</option>
    <option value="6" style="text-indent: 0px;">6+</option>
    <option value="5" style="text-indent: 0px;">5+</option>
    <option value="4" style="text-indent: 0px;">4+</option>
    <option value="3" style="text-indent: 0px;">3+</option>
    <option value="2" style="text-indent: 0px;">2+</option>
    <option value="1" style="text-indent: 0px;">1+</option>
  </select>
  </p>
<p>Quality:
  <label class="label">Quality:</label>
  <select name="Quality" id="Quality">
    <option value="All" style="text-indent: 0px;" selected="selected">All</option>
    <option value="1080p" style="text-indent: 0px;">1080p</option>
    <option value="3D" style="text-indent: 0px;">3D</option>
    <option value="480p" style="text-indent: 0px;">480p</option>
    <option value="720p" style="text-indent: 0px;">720p</option>
    <option value="DVD" style="text-indent: 0px;">DVD</option>
    <option value="HDRip" style="text-indent: 0px;">HDRip</option>
  </select>
</p>
<p>
  Year: 
  <input type="text" name="Year" /><br />

  </p>
<p>Trailer:
  <input type="text" name="Trailer" /><br />

</p>
<button id="sub">Submit</button>
</form>

<span id="result"></span/

</body>
</html>

db.php (connection to database)

<?php
    $conn = mysql_connect("localhost", "root", "spencer");
    $db   = mysql_select_db('movies');
?>

and addedinfo.php (It appears the info is going into the database but I do get these errors:
Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 15

Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 15

<?php
        include_once('db.php');

        if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
        $Movie_Name = $_POST['Movie_Name'];
        $Poster = $_FILES['Poster'];
        if (isset ($_POST['Genre'])){
        $GenreArray = $_POST['Genre'];
    }
        $IMDB_Rating = $_POST['IMDB_Rating'];
        $Quality = $_POST['Quality'];
        $Year = $_POST['Year'];
        $Trailer = $_POST['Trailer'];
        }
        if (mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$GenreArray', '$IMDB_Rating', '$Quality', '$Year', '$Trailer')"))
            echo "Successfull";
            else
            echo "Failed"
?>

I'm not worried about any security as this site will only be running on localhost, as it's just for me.
Thank you again for your time, and knodlege.

3
Contributors
30
Replies
109
Views
4 Years
Discussion Span
Last Post by broj1
1

The trouble is probably in the following statement on line 15:

if (mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$GenreArray', '$IMDB_Rating', '$Quality', '$Year', '$Trailer')"))

where you are trying to use the $GenreArray variable, which is of an array type instead of a string. I suppose you want to save genres as a comma separated string. In that case you have to implode the array $GenreArray using the comma as a glue before using it in a query:

if(isset($GenreArray)) {
    $genres = implode(',', $GenreArray);
} else {
    $genres = ''; // this is in case user selects nothing (to be on the safe side)
}

if (mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$genres', '$IMDB_Rating', '$Quality', '$Year', '$Trailer')"));

When you read the data back from the database use explode, to get an array.

The other option is to serialize the $GenreArray array before using it in a query.

if(isset($GenreArray)) {
    $genres = serialize($GenreArray);
} else {
    $genres = ''; // this is in case user selects nothing (to be on the safe side)
}

if (mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$genres', '$IMDB_Rating', '$Quality', '$Year', '$Trailer')"));

When you read data back from the database in this case use unserialize to get an array.

Edited by broj1

0

Thank you for the help, however now it's failing and giving this error

Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 18
Failed

However you have taught me something very usefull about arrays!

I tried both codes you posted - here is my updated code (I also added Synopsis, however it didn't fail when I tested it with the old code and synopsis. Any ideas?

<?php
        include_once('db.php');

        if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
        $Movie_Name = $_POST['Movie_Name'];
        $Poster = $_FILES['Poster'];
        if(isset($GenreArray)) {
        $genres = serialize($GenreArray);
        } else {
         $genres = ''; // this is in case user selects nothing (to be on the safe side)
        }
        $IMDB_Rating = $_POST['IMDB_Rating'];
        $Quality = $_POST['Quality'];
        $Year = $_POST['Year'];
        $Trailer = $_POST['Trailer'];
        $Synopsis = $_POST['Synopsis'];
        }
        if (mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$genres', '$IMDB_Rating', '$Quality', '$Year', '$Trailer','$Synopsis')"))
            echo "Successfull";
            else
            echo "Failed"
?>
1

OK, let's do some basic debugging. In order to do that you have to change the code slightly. First you have to assign a query to a variable (say $query) and then use this variable in a mysql_query command. But before using it we will display the query for inspection. Try this code:

    include_once('db.php');

    if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
    $Movie_Name = $_POST['Movie_Name'];
    $Poster = $_FILES['Poster'];
    if(isset($GenreArray)) {
    $genres = serialize($GenreArray);
    } else {
     $genres = ''; // this is in case user selects nothing (to be on the safe side)
    }
    $IMDB_Rating = $_POST['IMDB_Rating'];
    $Quality = $_POST['Quality'];
    $Year = $_POST['Year'];
    $Trailer = $_POST['Trailer'];
    $Synopsis = $_POST['Synopsis'];
    }

    // the query
    $query = "INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$genres', '$IMDB_Rating', '$Quality', '$Year', '$Trailer','$Synopsis')";

    // temporary debug code
    die($query);

    if (mysql_query ($query))
        echo "Successfull";
    else
        echo "Failed"; // you were missing a semocolon here !!!

This code will assemble the query, display it on the screen and stop. Please post the displayed query here.

0

Okay thank you.

Here's what I get

    Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 18
    INSERT INTO movieinfo VALUES ('','2 Days in New York','Array', '', '6', 'DVD', '2012', '','Manhattan couple Marion and Mingus, who each have children from prior relationships, find their comfortable family dynamic jostled by a visit from Marion's relatives. ')

Edited by guym: format

1

The third value in the query says 'Array'. The poster is supposed to be there, but it is an array that could not be converted to a string. In other words the code

$Poster = $_FILES['Poster'];

seems to be returning an array. Can you change the debug code (the die statement) to:

die($_FILES);

and post what you get displayed.

And another thing. The query gets also corrupted because of the single quote in the synopsis text (... Marion's relatives). You have to escape all the single quotes in the input fields for two reasons: first: they can corrupt your query (like in your example) and second: they enable the most dangerous attack - the SQL injection. To escape input use mysql_real_escape_string function like this:

$Synopsis = mysql_real_escape_string($_POST['Synopsis']);

The query will now look like this: ... Marion\'s relatives (see the escaped single quote). Use escaping on all fields.

Edited by broj1

0

Okay, I went ahead and change the debug code, along with changed the synopsis line. I'm not worried about attacks, as it's going to be an offline site - however that's great to know and good to fix the corrupt isssue as well

  Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 18

    Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 20
    Array
1

Sorry, my fault. The correct code is:

die(print_r($_FILES, 1));

Please post the output.

0

Notice: Array to string conversion in C:\xampp\htdocs\movies\addedinfo.php on line 18
Array ( [Poster] => Array ( [name] => 2 Days in New York.jpg [type] => image/jpeg [tmp_name] => C:\xampp\tmp\phpBB57.tmp [error] => 0 [size] => 21244 ) )

Np, I do appreciate the help!

1

As you can see the $_FILES['Poster'] is still an array. You have to change the code for the $Poster variable to:

$Poster = $_FILES['Poster']['name'];

or better also escape it (since it can contain quotes):

$Poster = mysql_real_escape_string($_FILES['Poster']['name']);

Once you do this you can remove the die statement (comment it out for now).

Edited by broj1

0

Successfull! Thank you so much!!
I'm not sure how the serialize gerne should appear in the database, but under gerne it's blank. the rest looks great!

0

Yes, 3 of them Comdey,Darma, and Romance for that movie.

0

it appears to be running the else ''

I put back in the first debut tool you taught me.

INSERT INTO movieinfo VALUES ('','2 Days in New York','2 Days in New York.jpg', '', '6', 'DVD', '2012', '','Manhattan couple Marion and Mingus, who each have children from prior relationships, find their comfortable family dynamic jostled by a visit from Marion\'s relatives.

0

Taking out the else gave me Notice: Undefined variable: genres in C:\xampp\htdocs\movies\addedinfo.php on line 16
INSERT INTO movieinfo VALUES ('','2 Days in New York','2 Days in New York.jpg', '', '6', 'DVD', '2012', '','Manhattan couple Marion and Mingus, who each have children from prior relationships, find their comfortable family dynamic jostled by a visit from Marion\'s relatives.')

0

O this is the code in question:

if(isset($GenreArray)) {
    $genres = serialize($GenreArray);
} else {
    $genres = ''; // this is in case user selects nothing (to be on the safe side)
}

Put the debug code just before it:

die(print_r($GenreArray, 1));

and post what you get.

0

Notice: Undefined variable: GenreArray in C:\xampp\htdocs\movies\addedinfo.php on line 6

0

Can you post the code for the form (the whole html file). I will check it in my environment.

0

Sure will do!

<html>
<head><title>Add Movie or Tv show</title></head>
<body>

<form enctype="multipart/form-data" id="myForm" action="addedinfo.php" method="post">
<table width="1233" height="593" border="0">
  <tr bgcolor="#FFFFFF">
    <th height="160" colspan="3" scope="col"><h1><strong>Add Movie or TV Show to Database</strong></h1></th>
  </tr>
  <tr>
    <td width="317" height="425"><p>               Movie Name:</p>
      <p> 
        <input type="text" name="Movie_Name" />
        <br />
      </p>
      <p>
        <label> Poster<br>
        </label>
        <input type="FILE" name="Poster">
        <br>
      </p>
      <p>Genre:</p>
      <p>
        <select multiple name="Genre[]" id="Genre">
          <option value="All" style="text-indent: 0px;" selected="selected">All</option>
          <option value="Action" style="text-indent: 0px;">Action</option>
          <option value="Adventure" style="text-indent: 0px;">Adventure</option>
          <option value="Animation" style="text-indent: 0px;">Animation</option>
          <option value="Biography" style="text-indent: 0px;">Biography</option>
          <option value="Comedy" style="text-indent: 0px;">Comedy</option>
          <option value="Crime" style="text-indent: 0px;">Crime</option>
          <option value="Documentary" style="text-indent: 0px;">Documentary</option>
          <option value="Drama" style="text-indent: 0px;">Drama</option>
          <option value="Family" style="text-indent: 0px;">Family</option>
          <option value="Fantasy" style="text-indent: 0px;">Fantasy</option>
          <option value="Film-Noir" style="text-indent: 0px;">Film-Noir</option>
          <option value="History" style="text-indent: 0px;">History</option>
          <option value="Horror" style="text-indent: 0px;">Horror</option>
          <option value="Mystery" style="text-indent: 0px;">Mystery</option>
          <option value="Romance" style="text-indent: 0px;">Romance</option>
          <option value="Sci-Fi" style="text-indent: 0px;">Sci-Fi</option>
          <option value="Short" style="text-indent: 0px;">Short</option>
          <option value="Sport" style="text-indent: 0px;">Sport</option>
          <option value="Thriller" style="text-indent: 0px;">Thriller</option>
          <option value="War" style="text-indent: 0px;">War</option>
          <option value="Western" style="text-indent: 0px;">Western</option>
        </select>
      </p>
      <p>
        <label>IMDB Rating:</label>
      </p>
      <p>
        <select name="IMDB_Rating" id="IMDB_Rating">
          <option value="0" style="text-indent: 0px;" selected="selected">All</option>
          <option value="9.9" style="text-indent: 0px;">10</option>
          <option value="9" style="text-indent: 0px;">9+</option>
          <option value="8" style="text-indent: 0px;">8+</option>
          <option value="7" style="text-indent: 0px;">7+</option>
          <option value="6" style="text-indent: 0px;">6+</option>
          <option value="5" style="text-indent: 0px;">5+</option>
          <option value="4" style="text-indent: 0px;">4+</option>
          <option value="3" style="text-indent: 0px;">3+</option>
          <option value="2" style="text-indent: 0px;">2+</option>
          <option value="1" style="text-indent: 0px;">1+</option>
        </select>
      </p></td>
    <td width="900"><p>&nbsp;</p>
      <p>Quality:
        <label class="label">Quality:<br>
        </label>
        <select name="Quality" id="Quality">
          <option value="All" style="text-indent: 0px;" selected="selected">All</option>
          <option value="1080p" style="text-indent: 0px;">1080p</option>
          <option value="3D" style="text-indent: 0px;">3D</option>
          <option value="480p" style="text-indent: 0px;">480p</option>
          <option value="720p" style="text-indent: 0px;">720p</option>
          <option value="DVD" style="text-indent: 0px;">DVD</option>
          <option value="HDRip" style="text-indent: 0px;">HDRip</option>
        </select>
    </p>
      <p> Year:</p>
      <p>
        <input type="text" name="Year" />
        <br />
      </p>
      <p>Trailer: </p>
      <p>
        <input type="text" name="Trailer" />
        <br />
      </p>
      <p>Synopsis:</p>
      <p>
        <textarea cols="50" rows="4" name="Synopsis"></textarea>
      </p></td>
    <td width="900"><img src="Reel.jpg"  alt="" width="447" height="407" align="top"/></td>
  </tr>
</table>
<h1 align="left">
  <button id="sub">Submit</button></h1></form>

<span id="result"></span/


</body>
</html>
1

OK, it is obvious. Change the code:

if(isset($GenreArray)) {
    $genres = serialize($GenreArray);
} else {
    $genres = ''; // this is in case user selects nothing (to be on the safe side)
}

to:

if(isset($_POST['Genre'])) {
    $genres = serialize($_POST['Genre']);
} else {
     $genres = ''; // this is in case user selects nothing (to be on the safe side)
}

$GenreArray is not existing in this code.

Edited by broj1

0

Awesome It's working perfectly now!!!!!!! Thank you so much!

0

Now it's time to add a couple more to the database, then learn how to make the submit create a new page for each one from a temp page with place holders :)

0

Will do, thank you very much, you've made my weekend!

0

hello,
can anyone help me, I want to make an verification page, where a student can verify his/her Enrolment number, I have an access database for records of students, Student ID, name, DOB, name admission date, Enrolment number, etc. now while student put their ID & DOB and submit they can view their Enrolment number and other data too if input is correct. The database regularly updated and new student also can view their data. How to creat?

0

well I'm back.

I've made lots of changes so I'll post all the code again.

I'm still having issues creating a page when submiting the form.

I receive this echo "That movie does not exist or is not yet added, press back" for these lines:

// Select the movie from the movieinfo table
$sql = "SELECT * FROM movieinfo WHERE Movie_Name='$Movie_Name'";
$movie_query = mysql_query($sql);
// Now make sure that user exists in the table
$numrows = mysql_num_rows($movie_query);
if($numrows < 1){
    echo "That movie does not exist or is not yet added, press back";
    exit(); 

however the database is receiving all of the information still.

I have no idea on where to go from here to make that sumbit buttom create the new page.

Here is my index.php code:

<html>
<head><title>Add Movie or Tv show</title></head>
<body>
<?php include_once("template_pageTop.php"); ?>
<form enctype="multipart/form-data" id="myForm" action="addedinfo.php" method="post">
<table width="1233" height="582" border="0">
  <tr bgcolor="#FFFFFF">
    <th height="88" colspan="3" scope="col"><div align="left">Add Movie or TV Show to Database</div></th>
  </tr>
  <tr>
    <td width="317" height="477"><p>               Movie Name:</p>
      <p> 
        <input type="text" name="Movie_Name" />
        <br />
      </p>
      <p>
        <label> Poster<br>
        </label>
        <input type="FILE" name="Poster">
        <br>
      </p>
      <p>Genre:</p>
      <p>
        <select multiple name="Genre[]" id="Genre">
          <option value="All" style="text-indent: 0px;" selected="selected">All</option>
          <option value="Action" style="text-indent: 0px;">Action</option>
          <option value="Adventure" style="text-indent: 0px;">Adventure</option>
          <option value="Animation" style="text-indent: 0px;">Animation</option>
          <option value="Biography" style="text-indent: 0px;">Biography</option>
          <option value="Comedy" style="text-indent: 0px;">Comedy</option>
          <option value="Crime" style="text-indent: 0px;">Crime</option>
          <option value="Documentary" style="text-indent: 0px;">Documentary</option>
          <option value="Drama" style="text-indent: 0px;">Drama</option>
          <option value="Family" style="text-indent: 0px;">Family</option>
          <option value="Fantasy" style="text-indent: 0px;">Fantasy</option>
          <option value="Film-Noir" style="text-indent: 0px;">Film-Noir</option>
          <option value="History" style="text-indent: 0px;">History</option>
          <option value="Horror" style="text-indent: 0px;">Horror</option>
          <option value="Mystery" style="text-indent: 0px;">Mystery</option>
          <option value="Romance" style="text-indent: 0px;">Romance</option>
          <option value="Sci-Fi" style="text-indent: 0px;">Sci-Fi</option>
          <option value="Short" style="text-indent: 0px;">Short</option>
          <option value="Sport" style="text-indent: 0px;">Sport</option>
          <option value="Thriller" style="text-indent: 0px;">Thriller</option>
          <option value="War" style="text-indent: 0px;">War</option>
          <option value="Western" style="text-indent: 0px;">Western</option>
        </select>
      </p>
      <p>
        <label>IMDB Rating:</label>
      </p>
      <p>
        <select name="IMDB_Rating" id="IMDB_Rating">
          <option value="0" style="text-indent: 0px;" selected="selected">All</option>
          <option value="9.9" style="text-indent: 0px;">10</option>
          <option value="9" style="text-indent: 0px;">9+</option>
          <option value="8" style="text-indent: 0px;">8+</option>
          <option value="7" style="text-indent: 0px;">7+</option>
          <option value="6" style="text-indent: 0px;">6+</option>
          <option value="5" style="text-indent: 0px;">5+</option>
          <option value="4" style="text-indent: 0px;">4+</option>
          <option value="3" style="text-indent: 0px;">3+</option>
          <option value="2" style="text-indent: 0px;">2+</option>
          <option value="1" style="text-indent: 0px;">1+</option>
        </select>
      </p>
      <p>Location: </p>
      <p>
        <input type="text" name="Location" value="file:///" /> <br />

    <td width="900"><p>&nbsp;</p>

      <p>Quality:
        <label class="label">Quality:<br>
        </label>
        <select name="Quality" id="Quality">
          <option value="All" style="text-indent: 0px;" selected="selected">All</option>
          <option value="1080p" style="text-indent: 0px;">1080p</option>
          <option value="3D" style="text-indent: 0px;">3D</option>
          <option value="480p" style="text-indent: 0px;">480p</option>
          <option value="720p" style="text-indent: 0px;">720p</option>
          <option value="DVD" style="text-indent: 0px;">DVD</option>
          <option value="HDRip" style="text-indent: 0px;">HDRip</option>
        </select>
    </p>
      <p> Year:</p>
      <p>
        <input type="text" name="Year" />
        <br />
      </p>
      <p>Trailer: </p>
      <p>
        <input type="text" name="Trailer" />
        <br />
      </p>
      <p>Synopsis:</p>
      <p>
        <textarea cols="50" rows="4" name="Synopsis"></textarea>
      </p></td>
    <td width="900"><img src="Reel.jpg"  alt="" width="447" height="407" align="top"/></td>
  </tr>
</table>
<p>&nbsp;</p>
<h1 align="left">
<button id="sub">Submit</button></h1></form>


</body>
</html>

and my addedinfo.php code

<?php
include_once('db.php');
    if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
    $Movie_Name = $_POST['Movie_Name'];
    $Poster = mysql_real_escape_string($_FILES['Poster']['name']);
    if(isset($_POST['Genre'])) {
    $genres = serialize($_POST['Genre']);
} else {
     $genres = ''; // this is in case user selects nothing (to be on the safe side)
};
        $IMDB_Rating = $_POST['IMDB_Rating'];
    $Quality = $_POST['Quality'];
    $Year = $_POST['Year'];
    $Trailer = $_POST['Trailer'];
    $Synopsis = mysql_real_escape_string($_POST['Synopsis']);
    $Location = mysql_real_escape_string($_POST['Location']);
    }
    // the query
       mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$genres', '$IMDB_Rating', '$Quality', '$Year', '$Trailer','$Synopsis', '$Location' )");


    // Creat directory foler to hold movies files
    if (!file_exists("moviefolder/$Movie_Name")) {
        mkdir("moviefolder/$Movie_Name", 0755);
    }


// Initialize any variables that the page might echo

$Movie_Name = "";
$Poster = "";
$genres = "";
$IMDB_Rating = "";
$Quality = "";
$Year = "";
$Trailer = "";
$Synopsis = "";
$Location = "";


// Select the movie from the movieinfo table
$sql = "SELECT * FROM movieinfo WHERE Movie_Name='$Movie_Name'";
$movie_query = mysql_query($sql);
// Now make sure that user exists in the table
$numrows = mysql_num_rows($movie_query);
if($numrows < 1){
    echo "That movie does not exist or is not yet added, press back";
    exit(); 

// Fetch the movie row from the query above
while ($row = mysql_fetch_array($movie_query, mysql_ASSOC)) {
    $Movie_Name = $row["Movie_Name"];
    $Poster = $row["Poster"];
    $genres = $row["genres"];
    $$IMDB_Rating = $row["$IMDB_Rating"];
    $Quality = $row["Quality"];
    $Year = $row["Year"];
    $Trailer = $row["Trailer"];
    $Synopsis = $row["Synopsis"];
    $Location = $row["Location"];
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $Movie_Name; ?></title>

</head>
<body>
<?php include_once("template_pageTop.php"); ?>
<div id="pageMiddle">
  <h3><?php echo $Movie_Name; ?></h3>
    <p><?php echo $Poster; ?></p>
  <p>Synopsis: <?php echo $Synopsis; ?></p>
  <p>IMDB Rating: <?php echo $IMDB_Rating; ?></p>
  <p><?php echo $genres; ?></p>
  <p>Year: <?php echo $Year; ?></p>
  <p><?php echo $Quality; ?></p>
  <p><?php echo $Trailer; ?></p>
  <p><?php echo $Location; ?></p>
</div>
</body>
</html>

Thanks again for all of your help, and talk to you soon! :p it's 5:30 am maybe I just need some sleep to see what's wrong.

0

Okay, I'm really lost right now.

I'm trying to create a new page generated by the form.
So once you fill in the form it would create a new page for that movie, however the way I have it coded right now once you submit the form it just goes to one page that reads out everything in the database.

I have no idea on how to do this.

Here is the current addedinfo.php

<?php
include_once('db.php');
    if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
    $Movie_Name = $_POST['Movie_Name'];
    $Poster = mysql_real_escape_string($_FILES['Poster']['name']);
    if(isset($_POST['Genre'])) {
    $genre = serialize($_POST['Genre']);
} else {
     $genre = ''; // this is in case user selects nothing (to be on the safe side)
};
        $IMDB_Rating = $_POST['IMDB_Rating'];
    $Quality = $_POST['Quality'];
    $Year = $_POST['Year'];
    $Trailer = $_POST['Trailer'];
    $Synopsis = mysql_real_escape_string($_POST['Synopsis']);
    $Location = mysql_real_escape_string($_POST['Location']);
    }
    // the query
       mysql_query ("INSERT INTO movieinfo VALUES ('','$Movie_Name','$Poster', '$genre', '$IMDB_Rating', '$Quality', '$Year', '$Trailer','$Synopsis', '$Location' )");


    // Creat directory foler to hold movies files
    if (!file_exists("moviefolder/$Movie_Name")) {
        mkdir("moviefolder/$Movie_Name", 0755);
    }


// Select the movie from the movieinfo table
$sql = "SELECT * FROM movieinfo";
$movie_query = mysql_query($sql);
// Now make sure that user exists in the table
$numrows = mysql_num_rows($movie_query);
if($numrows < 1){
    echo "That movie does not exist or is not yet added, press back";
    exit(); 
}
?>

<html>
<head>
<title><?php echo $Movie_Name; ?></title>
<?php include_once("template_pageTop.php"); ?>
</head>
<body>
</body>
</html>

<div id="pageMiddle">
<?php
$query = "SELECT * FROM movieinfo";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
    echo $row ['Movie_Name'] , "<br />",  $row ['Poster'] , "<br />",  $row ['Genre'] , "<br />",  $row ['IMDB_Rating'] , "<br />", $row ['Quality'] , "<br />",  $row ['Year'] , "<br />",  $row ['Trailer'] , "<br />",  $row ['Synopsis'] , "<br />",  $row ['Location'];
echo "<br />";
}
?>
</div>
0

You do not have to read from the database since you already have all data about the added movie (which you want to display if I understood you). Just go like this:

<html>
<head>
<title><?php echo htmlspecialchars($_POST['Movie_Name']); ?></title>
<?php include_once("template_pageTop.php"); ?>
</head>
<body>
<p>Movie name: <?php echo htmlspecialchars($_POST['Movie_Name']); ?> <br>
<p>Poster: <?php echo htmlspecialchars($_POST['Poster']); ?> <br>
...
</p>

</body>
</html>

As you can see I have used the htmlspecialchars function to replace the dangerous tags that should not get into the html from the form (like <script> tag)

Edited by broj1

0

Will this way create and then save that new page so it can be revisited/ searched for?

My overall goal is to make something like this http://yify-torrents.com/browse-movie

Main page would be a list showing the most recent added movies, each movie would have its own page and everything would be searchable.

Maybe I've been going about it all the wrong way?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.