php电影搜索栏使用变量

时间:2016-03-25 20:43:45

标签: php html arrays

我正在尝试创建一个页面,当有人在搜索栏中键入特定的电影时,它会转到我的服务器上带有嵌入式vlc播放器的页面并播放该电影。我尝试将userinput存储为使用php的数组中的变量,但我得到两个错误数组之一到字符串转换或未定义的索引!

我使用pregmatch扫描包含我的电影的txt文件并希望它 获取与用户输入最匹配的文件名,并将其添加到我的嵌入式播放器的src = $变量中,因此必须有一个页面才能播放100个或更多电影。

继续使用php源代码和嵌入式视频播放器html

html视频嵌入:     ' />      和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 ";


        }
    } 

&GT;

0 个答案:

没有答案