IE7和IE8中网站的意外重定向

时间:2012-01-11 17:35:32

标签: php internet-explorer internet-explorer-8 internet-explorer-7

之前我尝试过这个问题并且没有提供足够的信息,所以这里有更多细节。我在托管网站上有一个页面,要求访问者在表单中输入编码字符串。提交时,代码会构建一个文件名,并从文本文件中获取一些简单的数据。

在FF和Safari中一切正常,但在Internet Explorer 7和Internet Explorer 8中测试时,访问者会被重定向到站点主页。

同样意外的重定向发生在网站的其他地方。我希望我能在这里找出问题,我可以解决其他问题。

以下是代码:

<?php

    session_start();
    ob_start;

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Advisor Survey - 2012 Predictive Questions</title>

<link href="css/surv_ver2.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/s_table.css" rel="stylesheet" type="text/css" media="screen" />

</head>

<body>

    <div id="header">


    </div> <!-- close header -->

    <div id="wrapper">

        <div id="mid_cont">

            <div id="mid_left">


            </div> <!-- close mid_left -->

            <div id="mid_col">

                <div id="mid_col_inner">

                <h2 class="p_head">Scoring Details</h2>
                <p class="p_text">Want to learn more about how your site compares to others in your market? We employed tools to evaluate your web site from a high-level marketing perspective.</p>
                <p class="p_text">All of our sample tests mimic search engine functionality. Check our site to see where your score falls in the overall Denver market.</p>


                </div> <!-- close mid_col_inner -->


            </div> <!-- close mid_col -->

            <div id="mid_center">

                <div id="top_cent">

                    <img src="images/revenue_subhead.png" />

                </div> <!-- close top_cent -->

                <div id="mid_cent">

                    <p class="mid_col_text">Enter the code (no punctuation or spaces) from our communication with you to see your score.</p>


                </div> <!-- close mid_cent -->

                <div id="bot_cent">

                    <div id="bot_left">

                        <form method="POST" action="<?php $_SERVER['PHP_SELF'] ?> " />

                        <label id="label2">Enter code: </label>
                        <input type="text" name="code" id="code" />


                        <input type="submit" name="submit" id="code_submit" />
                        </form>

                    </div> <!-- close bot_left -->

                    <div id="bot_right">

                        <?php 

                            if (($_POST['submit']) and (empty($_POST['code']))) {
                                echo "<br/><br/>";
                                print "<p class=\"spl_p\"> Please select choice!</p>";
                            }

                            if (!empty($_POST['code']))  {
                                $response = $_POST['code'];
                                echo $response;

                                $test_name = $response . ".txt";

                            $test_name = "../id_advisors/$test_name";
                            if (!file_exists($test_name)) {
                                echo "Please re-enter code!";
                                exit();
                            }
                            }
                            if (!empty($_POST['code'])) {
                            echo $test_name;
                            // read in the details of the file for each firm

                            $pointer = fopen("../id_advisors/$test_name", "r");
                            $data_line = fgets($pointer, 1096);
                            fclose($pointer);

                            $file_array = explode("\t", $data_line);

                            foreach ($file_array as $item) {

                            $item = $file_array;


                            $firm_name = $file_array[0];
                            $mkt_id = $file_array[1];
                            $site_id = $file_array[2];
                            $score = $file_array[3];
                            $pages = $file_array[4];
                            $traffic_rank = $file_array[5];
                            $in_links = $file_array[6];
                            $start_date = $file_array[7];

                            }
                            }
                            ?>

                            <table id="form_2" cellpadding="-3">

                            <tr><td width="100">Firm name: </td><td><input type="text" name="f_name" id="f-name" value="<?php echo $firm_name; ?>" /></td></tr>
                            <tr><td width="100">Market ID: </td><td><input type="text" name="mkt" id="mkt" value="<?php echo $mkt_id; ?>" /></td></tr>
                            <tr><td width="100">URL : </td><td><input type="text" name="url" id="url" value="<?php echo $site_id; ?>" /></td></tr>
                            <tr><td width="100">Score: </td><td><input type="text" name="score" id="score" value="<?php echo $score; ?>" /></td></tr>
                            <tr><td width="100">Index pages: </td><td><input type="text" name="pages" id="pages" value="<?php echo $pages; ?>" /></td></tr>
                            <tr><td width="100">Traffic: </td><td><input type="text" name="traff" id="traff" value="<?php echo $traffic_rank; ?>" /></td></tr>
                            <tr><td width="100">Inbound links: </td><td><input type="text" name="i_links" id="i_links" value="<?php echo $in_links; ?>" /></td></tr>
                            <tr><td width="100">Test date: </td><td><input type="text" name="t_date" id="t_date" value="<?php echo $start_date; ?>" /></td></tr>

                            </table>

                    </div> <!-- close bot_right -->

                </div> <!-- close bot_cent -->

            </div> <!-- close mid_left -->

            <div id="mid_right">


            </div> <!-- close mid_left -->

        </div> <!-- close mid_cont -->

        <div id="footer">



        </div> <!-- footer -->
        <div id="sub_foot">

            <p>Copyright 2012  |  Lighthouse Pacific Group, LLC  -  All Rights Reserved</p>

        </div> <!-- close sub_foot -->

    </div> <!-- close wrapper -->

</body>
</html>

1 个答案:

答案 0 :(得分:2)

您正在关闭创建它的同一行上的FORM元素:

 <form method="POST" action="<?php $_SERVER['PHP_SELF'] ?> " />

将其更改为:

<form method="POST" action="<?php $_SERVER['PHP_SELF'] ?> ">

我不确定是否会明确修复您的重定向问题,但我知道如果您不解决此问题,它会导致您的表单提交出现问题。

修改

好的我第一次忽略了这个问题,这里是修复,改变了上面列出的相同代码行,但是包含了echo ...

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

或简化:

<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">