douxi9245 2014-11-05 20:42
浏览 6
已采纳

为什么不需要的脚本出现在网页中? [关闭]

I have written a HTML and PHP code which should show a survey form and invite you to enter your email address and have a submit button for you to click. However, when I "run" the code, I get some gibberish which I wrote in my code, which I did not expect to appear on my survey form. The code that I have written is as follows:

            session_start();

            if (!empty($_POST['posted']) && !empty($_POST['email'])){
            $folder = "surveys/" . strtolower($_POST['email']);

            // send path information to the session
            $_SESSION['folder'] = $folder;

            if(!file_exists($folder)) {
            // make the directory and then add the empty files
            mkdir($folder, 0777, true);
           }

            header("Location: 08_6.php");
           }
        else { ?>

      <html>
       <head>
         <title>Files and folders - Online Survey</title>
       </head>

       <body bgcolor="white"  text="black">

       <h2>Survey Form</h2>

       <p>Please enter your email address to start recording your comments</p>

                <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
              <input type="hidden" name="posted" value="1">
            <p>Email address: <input type="text" name="email" size="45" /><br />
          <input type="submit" name="submit" value="Submit"></p>
        </form>
       </body>
     </html>
   <?php }

What's happening is that I'm getting:

session_start(); if (!empty($_POST['posted']) && !empty($_POST['email'])){...

and whole bunch of other stuff appearing at the top of the webpage, which is certainly not what I want. Could one of you experts please tell me what I'm doing wrong?

  • 写回答

1条回答 默认 最新

  • douwen3083 2014-11-05 20:44
    关注

    You have not included an opening <?php tag in your page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序