带有html的php文件正在评论出php

时间:2013-09-21 17:55:53

标签: php html

您好我有以下代码,浏览器正在注释掉php。该文件保存.php然而没有任何帮助。我搜索了这个论坛,没有任何作用。

    

<html>
    <head>

    <!--<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>-->
        <title>
            Golden Acres
        </title>
        <link href="css/mystyle.css" rel="stylesheet" type="text/css"/>

    </head>
    <body class="center">
        <table class="main_tables">
            <tr>
                <td rowspan="2" >
                    <img class="main_logo" src="images/logo2.gif" alt="logo"/>
                </td>
                <td id="main_nav_menu"  valign="bottom">
                    <table cellspacing="2" >
                        <tr>
                            <td id="slogan_home" colspan="6" valign="middle">
                                "delivering fresh close to your home"

                            </td>
                        </tr>
                        <tr id="extra_row"><td></td></tr>
                        <tr>
                            <td class="main_nav_menu" align="center">
                                <a class="main_nav_menu_links"  href="index.html">home</a>
                            </td>
                            <td class="main_nav_menu">
                                <a class="main_nav_menu_links"  href="about_us.html">about us</a>
                            </td>
                            <td class="main_nav_menu" >
                                <a class="main_nav_menu_links" href="boxes.html">boxes</a>
                            </td>
                            <td class="main_nav_menu">
                                <a class="main_nav_menu_links" href="shop.html">Shop</a>
                            </td>
                            <td class="main_nav_menu">
                                <a class="main_nav_menu_links" href="events.html">events</a>
                            </td>
                            <td class="main_nav_menu">
                                <a class="main_nav_menu_links" href="contact.html">Contact Us</a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <?php
            if(isset($_POST['submit'])){
            $submit = $_POST['submit'];

            if(isset($_POST['register_fname'])&&($_POST['register_lname'])&&($_POST['register_uname'])&&($_POST['register_password'])){
                $firstname = $_POST['register_fname'];
                $lastname = $_POST['register_lname'];
                $username = $_POST['register_uname'];
                $password = $_POST['register_password'];

                if(isset($firstname)&&isset($lastname)&&isset($username)&&isset($password)){
                    echo 'Isset is ok';
                }
                else
                {
                    echo 'Isset is not ok';
                }
            }
        }
        ?>
        <form action="register.php" method="POST">
        <input type="submit" name="submit">
    </form>
    </body>
</html>

当我在浏览器中检查元素时,它显示为:<!-- php .... ?-->

帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

在Html之前的页面开头添加,甚至是DOCTYPE声明标记:

<?php include "register.php"; ?>
<!DOCTYPE html>
<html lang="en">

并将您的代码移至此文件&lt; register.php&gt;

然后使用这样的表格:

<form id="" name="" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>" role="form">
<input type="submit" name="submit" value="Send" >
</form>

我希望这会有所帮助

答案 1 :(得分:0)

对不起,这是我的一个愚蠢的错误。