我最近用PHP邮件创建了一个联系表单,最终正常工作。但是,成功消息是打破我的页面并显示在左上角而不是在表单下面。如下所示。
这是HTML:
<form method="POST">
<table border="1">
<tr>
<td><label for="name" class="g">Name</label></td>
<td><input id="name" name="name" type="text" autofocus></td>
</tr>
<tr>
<td><label for="address" class="g">Address</label></td>
<td><textarea rows="3" id="address" name="address" cols="50"></textarea></td>
</tr>
<tr>
<td><label for="number" class="g">Contact number</label></td>
<td><input id="number" name="number" type="text" autofocus></td>
</tr>
<tr>
<td><label for="email" class="g">Email</label></td>
<td><input id="email" name="email" type="text" placeholder="example@domain.com" autofocus></td>
</tr>
<tr>
<td><label for="message" class="g">Enquiry</label></td>
<td><textarea rows="3" id="message" name="message" cols="50"></textarea></td>
</tr>
</table>
<input type="submit" value="Submit" name="submit">
<?php
if ($success) {
echo $success;
}
?>
</form>
它还会在表单下方的页面中间创建一个巨大的空白区域。有人知道为什么吗?或者我将如何调试它?
答案 0 :(得分:3)
你应该将它放在div或span
中<div style="text-align:center;"> <?php
if ($success) {
echo $success;
}
?>
</div>
答案 1 :(得分:0)
请尝试以下代码:
<form method="POST">
<table border="1">
<tr>
<td><label for="name" class="g">Name</label></td>
<td><input id="name" name="name" type="text" autofocus></td>
</tr>
<tr>
<td><label for="address" class="g">Address</label></td>
<td><textarea rows="3" id="address" name="address" cols="50"></textarea></td>
</tr>
<tr>
<td><label for="number" class="g">Contact number</label></td>
<td><input id="number" name="number" type="text" autofocus></td>
</tr>
<tr>
<td><label for="email" class="g">Email</label></td>
<td><input id="email" name="email" type="text" placeholder="example@domain.com" autofocus></td>
</tr>
<tr>
<td><label for="message" class="g">Enquiry</label></td>
<td><textarea rows="3" id="message" name="message" cols="50"></textarea></td>
</tr>
<?php
if ($success) {?>
<tr><td colspan="2">
<?php echo $success; ?>
</td></tr>
<?php }
?>
</table>
<input type="submit" value="Submit" name="submit">
</form>