Php 如何将变量解析为header()页

Php 如何将变量解析为header()页,php,html,forms,Php,Html,Forms,我在一页上有这个代码 ` 问题是我想在searchpage.php页面上使用变量$keywords。我怎样才能做到这一点 编辑:search-page.php的代码是: <?php include_once( 'headersearch.php' ); include ('includes/func.inc.php'); global $variable; ?> <table id="content-area">

我在一页上有这个代码

`


问题是我想在searchpage.php页面上使用变量$keywords。我怎样才能做到这一点

编辑:search-page.php的代码是:

        <?php include_once( 'headersearch.php' );
include ('includes/func.inc.php');
global $variable;
     ?>


        <table id="content-area">

            <tr>
                <td id="search-page" valign="top">


                     <?php

    $results = search_results($keywords);
                $results_num =  count($results);
                if($results_num == 1){
                    $s = "result";
                }
                else{
                    $s = "results";
                }
                echo '<p>Your Search for <strong>',$keywords,'</strong> returned <strong>',$results_num,'</strong> ',$s,'</p>';
                foreach($results as $results){
                    ?>
                    <table id="posts">
                <tr height="25px"><td><h1><?php echo $results['article_title'] ; ?></h1></td></tr>
                <tr><td><h2><span>Posted on</span> :<?php echo date('l jS',$results['article_timestamp']) ?> <span>By</span>: BMC </h2></td></tr>
                <tr><td><h3><?php echo substr($results['article_content'], 0, 300) ; ?>[...]</h3></td></tr>
                <tr><td><a href="single.php?id=<?php echo $results['article_id']; ?>" title="TEST" class="button">Read Along</a></td></tr>
                </table>

                    <?php
                }
                ?>


                    <?php   include_once('sidebar.php'); ?>

            </form>

                </td>
            </tr>



<?php include_once( 'footer.php' ); ?>      

发布日期:By:BMC
[...]

请尽快帮助我psible

如果您直接将搜索表单提交到
search page.php
并将表单验证代码放入该脚本中,那就更好了

也就是说,您不需要在这个页面上进行sql/html转义,因为您没有在sql或html上下文中使用表单数据。尝试以下基本系统:

$keywords = $_POST['keywords'];

header('Location: search-page.php?keywords=' . urlencode($keywords));

在searchpage.php页面上使用变量$keywords是什么意思?您可以发布searchpage.php页面的代码吗?在其他
s中嵌套
s是无效的,并且会导致意外行为。您还应该在头函数调用后添加exit。抱歉。。当我复制一个代码,然后我应该从url中获取关键字时,这是一个错误?@BogdanConstantin:现在,在你的
搜索页面.php
,你可以简单地执行
$keywords=$\u get['keywords'
$\u在搜索页面中获取['keywords']
。与您在任何其他php脚本中获得的查询变量完全相同。致命错误:无法在A:\wamp\www\includes\func.inc.php:4中的A:\wamp\www\includes\func.inc.php第39行的第39行中重新声明搜索结果()
$keywords = $_POST['keywords'];

header('Location: search-page.php?keywords=' . urlencode($keywords));