把你的PHP脚本放到HTML静态代码后面.

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Language" content="en" />
    <meta name="GENERATOR" content="PHPEclipse 1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>title</title>
    </head><?php
    if(isset($_POST["submit"]))
    {
    ?><script>alert("success");</script><?php
    }
    else
    {
    ?><script>alert("fail");</script><?php
    }

    ?>
    <body>
    <form  name="form" method="post">
    <input type="submit" name="submit" value="close">
    </form>
    </body>
    </html>
    原因:
    语言声明应出现在页面的内容的
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Language" content="en" />
    <meta name="GENERATOR" content="PHPEclipse 1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>title</title>
    </head>
    <body>
    <form action="text.php" name="form" method="post">
    <input type="submit" name="submit" value="close">
    </form>
    </body>
    </html><?php
    if(isset($_POST["submit"]))
    {
    ?>
    <script language=javascript>
    alert("success");
    </script>
    <?php
    }
    else
    {
    ?>
    <script>alert("fail");</script>
    <?php
    }
    ?>
      

  3.   

    这样可以提交后弹出窗口撒。<?php
    if(isset($_POST["submit"]))
    {
    ?>
    <script>alert("success");</script>
    <?php
    }
    else
    {
    ?>
    <script>alert("fail");</script><!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>无标题文档</title>
    </head><body>
    <form action="test.php" name="form" method="post">
    <input type="submit" name="submit" value="close">
    </form>
    </body>
    </html>
    <?php
    }
    ?>
      

  4.   

    同意楼上的,不过也可以分成2个文件,test.php和xx.html