I am trying to create a page that when someone types a specific movie in the search bar it goes to a page on my server with an embedded vlc player and plays that movie. I tried by storing the userinput as a variable in an array using php but i either get one of two errors array to string conversion or undefined index!
I'm using pregmatch to scan a txt file containing my movies and want it to take the file name that most matches the user input and add it to the src = $variable of my embeded player so i nly have to have one page to play 100 or more movies.
heres the php source and the embeded video player html
html video embed : ' /> and the source code for pregmatch!
<div class="search" align = "center">
<form action="MovieMatch.php" method ="post">
<input type="text" name="userget" />
<input type="submit"name="submit" value="<?php$pick ?>" />
</form>
</div>
<h1 align = "center" class="text-primary">Search our Movies!</h1>
<div class="images" >
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
if(isset($_POST['submit'])){
$submit = $_POST ["userget"];//storing input
$file = 'movielist.txt';
// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($file);
// escape special characters in the query
$pattern = $submit;
// finalise the regular expression, matching the whole line
$pattern = "/^.*$pattern.*\$/m";
$handle = fopen("movielist.txt", "r");
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
$pick = implode("\n", $matches[0]);
echo $pick[1];
echo "Found matches:\n";
echo '<a href="http://127.0.0.1/alphastream/categories/'.$pick. '" class = "button">click me!</a>'; // this is my fix bu
}
else{
echo "No matches ";
}
}
?>