Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- //if(isset($_SESSION['views'])) $_SESSION['views'] = $_SESSION['views']+ 1;
- //else $_SESSION['views'] = 1;
- /*if(isset($_SESSION['movies'])) $_SESSION['movies'] = $_SESSION['movies'];
- else $_SESSION['movies'] = $moviesIn;*/
- if(isset($_SESSION['movies'])) $_SESSION['movies'] = $_SESSION['movies'];
- else $_SESSION['movies'] = GetMovies();
- //print_r($_SESSION['movies']);
- /*
- if($_POST['load']) LoadList();
- else if($_POST['save']) SaveList();
- else if($_POST['add']) AddList();
- else if($_POST['remove']) RemoveList();
- else if($_POST['clear']) ClearList();
- else if($_POST['count']) CountList();
- else echo "very strange error";
- */
- function GetMovies() {
- //open file, get contents, close file
- $filename = "./movies.in";
- $handle = fopen($filename, "r");
- $contents = fread($handle, filesize($filename));
- fclose($handle);
- //get an array of movies
- $moviesIn = explode("\n", $contents);
- //cut out that stupid newline
- for($i=0; $i<count($moviesIn); $i++) {
- if($i<(count($moviesIn)-1)) {$trimmed = substr($moviesIn[$i], 0, strlen($moviesIn[$i])-1);}
- else {$trimmed = $moviesIn[$i];}
- $moviesIn[$i] = $trimmed;
- }
- return $moviesIn;
- }
- /*
- function LoadList() {
- global $output;
- for($i=0; $i<count($_SESSION['movies']); $i++)
- $output .= "<option value=\"$i\">".$_SESSION['movies'][$i]."</option>\n";
- //return $output;
- }
- //$_SESSION['movies'] = $_SESSION['movies'];
- //print_r($_SESSION['movies']);
- //echo $_SESSION['movies'][0];
- //echo $_SESSION['movies'][1];
- //echo $_SESSION['movies'][2];
- */
- //check out the arrayUnique() function
- /**/
- ?>
- <html>
- <head>
- <title>Video Rentals</title>
- <style type="text/css">
- form {
- text-align: center;
- border: 1px solid;
- width: 600px;
- margin: 0 auto 0 auto;
- }
- input {
- width: 160px;
- margin: 0px;
- }
- </style>
- </head>
- <body>
- <?php print_r($_SESSION['movies']); ?>
- <form>
- <h1>Video Rentals</h1>
- <br />
- <br />
- <input type="text" name="TBA" value="" />
- <br />
- <select name="movies">
- <?php
- //display the dropdown box of current movies
- //echo $output
- ?>
- </select>
- <br />
- <input type="submit" name="load" value="Load Movie List" />
- <input type="submit" name="save" value="Save Movie list" />
- <input type="submit" name="add" value="Add Movie" />
- <br />
- <input type="submit" name="remove" value="Remove Movie" />
- <input type="submit" name="clear" value="Clear Movie List" />
- <input type="submit" name="count" value="Display Movie Count" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement