我想实现一个联系表单,但浏览器将 php 代码显示为纯文本。这是代码:
<div id="main-container">
<div id="form-container">
<h1>Fancy Contact Form</h1>
<h2>Drop us a line and we will get back to you</h2>
<form id="contact-form" name="contact-form" method="post" action="submit.php">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="15%"><label for="name">Name</label></td>
<td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td><label for="email">Email</label></td>
<td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
<td> </td>
</tr>
<tr>
<td><label for="subject">Subject</label></td>
<td><select name="subject" id="subject">
<option value="" selected="selected"> - Choose -</option>
<option value="Question">Question</option>
<option value="Business proposal">Business proposal</option>
<option value="Advertisement">Advertising</option>
<option value="Complaint">Complaint</option>
</select> </td>
<td> </td>
</tr>
<tr>
<td valign="top"><label for="message">Message</label></td>
<td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td>
<td valign="top"> </td>
</tr>
<tr>
<td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
<td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="Submit" />
<input type="reset" name="button2" id="button2" value="Reset" />
<?=$str?> <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td>
</tr>
</table>
</form>
<?=$success?>
</div>
<div class="tutorial-info">
This is a Tutorialzine demo. View the <a href="http://tutorialzine.com/2009/09/fancy-contact-form/">original tutorial</a>, or download the <a href="demo.zip">demo files</a>. </div>
</div>
所以,我得到了这些
<?=$_SESSION['post']['name']?>
<?=$_SESSION['post']['email']?>
<?=$_SESSION['post']['message']?>
以纯文本形式显示在表单字段中。做错了什么?请帮忙。