Reputation: 149
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.
Upvotes: 0
Views: 611
Reputation: 3542
<?=
is short form of <?php echo
. In WAMP Server, short tags are off by default. You can solve this problem in two ways :
Change <?=
to <?php echo
OR
Find php.ini file in wamp folder and change short_open_tag = On
Upvotes: 3