简体   繁体   中英

HTML showing PHP code written in value area

I have this HTML code. It is supposed to be a register form. It is using a Session to store the information in case something is wrong so that the user doesn't have to re-enter the information again. But somehow, it is writing the whole PHP code inside the value part. Yes it is in the format .php and I am using WAMP Server. I also tried to use APPServ but to no avail. Here is the code

 <form action="register.php" method="post">
    <h1>Register Form</h1>
    <table>
        <tr>
            <td>Login name:</td>
            <td><input type="text" name="login_name" value="<?=(!empty($_POST['login_name'])) ? $_POST['login_name'] : ''?>" /></td>
        </tr>
        <tr>
            <td>First name:</td>
            <td><input type="text" name="first_name" value="<?=(!empty($_POST['first_name'])) ? $_POST['first_name'] : ''?>" /></td>
        </tr>
        <tr>
            <td>Last name:</td>
            <td><input type="text" name="last_name" value="<?=(!empty($_POST['last_name'])) ? $_POST['last_name'] : ''?>" /></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input type="password" name="pw1" /></td>
        </tr>
        <tr>
            <td>Confirm password:</td>
            <td><input type="password" name="pw2" /></td>
        </tr>
        <tr>
            <td>Email:</td>
            <td><input type="text" name="email" value="<?=(!empty($_POST['email'])) ? $_POST['email'] : ''?>" /></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;"><input type="submit" name="register" value="Register!" /></td>
        </tr>
    </table>
</form>

The only problem I'm having is what I mentioned: The textboxes show the PHP code I wrote in the value part. Everything else is working fine. I am using Chrome in Window 8. I should also note that I sent this code to a friend and it worked just fine and the only difference we have is that he is using Windows 7.

<?= is short form of <?php echo . In WAMP Server, short tags are off by default. You can solve this problem in two ways :

  1. Change <?= to <?php echo

    OR

  2. Find php.ini file in wamp folder and change short_open_tag = On

<?=替换为<?php

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