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.

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

报告相同问题?

悬赏问题

  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题