简体   繁体   中英

php file with html in it is commenting out php

Hi I have the following code and the browser is commenting out the php. The file is saved .php however nothing helps. I've searched this forum and nothing works.

<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>

The when I inspect element in the browser it's displayed as : <!-- php .... ?-->

Help would be appreciated.

add at the begins of the page before Html and even DOCTYPE declaration tag :

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

and move your code to this file < register.php >

then use the form like this:

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

i hope this will help

抱歉,这是我的一个愚蠢的错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM