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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵