PHP执行AND显示为文本

时间:2015-01-13 18:21:33

标签: php

我的网站上有php,可以为多个网站创建搜索框。我只是设置了vhosts(子域)并将搜索目录移动到它。在这之后,php现在显示在页面上,以及成功执行。我不知道它是如何做到的,但确实如此。代码全部如下:

<html>
<body>

<?php
if (isset($_GET['q'])){
 $query = $_GET['q'];
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.google.co.uk/search?q=$query\">";
}

if (isset($_GET['p'])) {
 $yquery = $_GET['p'];
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://uk.search.yahoo.com/search?p=$yquery\">";
}

if (isset($_GET['yt'])) {
 $ytquery = $_GET['yt'];
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.youtube.com/results?search_query=$ytquery\">";

}

if (isset($_GET['amz'])) {
 $amzquery = $_GET['amz'];
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.amazon.co.uk/s/keywords=$amzquery\">";

}

if (isset($_GET['eby'])) {
 $ebyquery = $_GET['eby'];
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.amazon.co.uk/sch/i.html/_nkw=$ebyquery\">";

}
?>


<div id="searchForms">
<form id="gSearch" method="GET" action="http://www.google.co.uk/search"  />
<input type="text" name="q" placeholder="Google UK" value='' />
<input type="submit" value="Google Search"/>
</form>

<form id="ySearch" method="GET" action="http://uk.search.yahoo.com/search" />
<input type="text" name="p" placeholder="Yahoo" value='' />
<input type="submit" value="Yahoo Search"/>
</form>

<form id="ytSearch" method="GET" action="http://www.youtube.com/results" />
<input type="text" name="search_query" placeholder="YouTube" value='' />
<input type="submit" value="YouTube Search"/>
</form>

<form id="ebySearch" method="GET" action="http://www.EBay.co.uk/sch/i.html" />
<input type="text" name="_nkw" placeholder="EBay" value='' />
<input type="submit" value="EBay Search"/>
</form>

<form id="amzSearch" method="GET" action="http://www.amazon.co.uk/s/" />
<input type="text" name="keywords" placeholder="Amazon" value='' />
<input type="submit" value="Amazon Search"/>
</form>


</div>


</body>
</html>

2 个答案:

答案 0 :(得分:0)

这不是您搜索的内容,但最好使用

header('Location: http://www.google.co.uk/search?q='.quotemeta($query));

和切换/案例......

非常重要的是,检查您对安全模式的输入。 The Open Web Application Security Project

答案 1 :(得分:0)

PHP不是nescassery,实际上对搜索框没有任何作用。可以并且应该删除<?php?>之间的所有内容,因为表单的action属性已经在进行重定向。