我已经创建了一个工作正常的表单,但是当我把它放在一个表中时,它总是认为表单不完整 - 有没有办法把它放在一个表中(所以看起来不错!)没有这个问题?
-----我的HTML ------
<h2 class="green">Interested in making life easier?</h2>
<form method="post" action="sendemail.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
Name:
<input type="text" name="visitor" size="25" />
<br />
Address:<input type="text" name="visitoradd" size="25" />
<br />
City:<input type="text" name="visitorcity" size="15" />
<br />
Postcode:<input type="text" name="visitorpost" size="15" />
<br />
Email:<input type="text" name="visitormail" size="25" />
<br />
Telephone Number:<input type="text" name="visitortel" size="25" />
<br />
Bookkeeping/Payroll:<select name="bp" size="1">
<option value=" Bookkeeping">Bookkeeping </option>
<option value=" Payroll ">Payroll</option>
</select>
<br />
Number of transactions: <input type="text" name="transcations" size="15" />
<br />
Number of employees:<input type="text" name="employees" size="15" />
<br />
Payroll weekly/monthly:<select name="pmw" size="1">
<option value=" Weekly">Weekly</option>
<option value=" Monthly">Monthly</option>
</select>
<br />
<br />
<INPUT TYPE="image" SRC="images/btnSubmit.png" ALT="Submit Form">
<br />
</form>
-----我的PHP -----
<?php
$visitor = $_POST['visitor'];
$visitoradd = $_POST['visitoradd'];
$visitorcity= $_POST['visitorcity'];
$visitorpost= $_POST['visitorpost'];
$visitormail = $_POST['visitormail'];
$visitortel = $_POST['visitortel'];
$bp = $_POST['bp'];
$transcations = $_POST['transcations'];
$employees = $_POST['employees'];
$pmw = $_POST['pmw'];
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Please enter valid e-mail.</h2>\n";
$badinput = "<h2>Click the back button to retry.</h2>\n";
echo $badinput;
die ("Thank you.");
}
if(empty($visitor) || empty($visitormail) || empty($visitorcity) || empty($visitorpost) || empty($visitoradd) || empty($visitortel) || empty($bp) || empty($transcations) || empty($employees) || empty($pmw) || empty($pmw))
{
echo "<h2>Please fill in all fields, click the back button to retry</h2>\n";
die ("Thank you.");
}
$message = "
Name: $visitor\n
Address: $visitoradd\n
City: $visitorcity\n
Post Code: $visitorpost\n
Email: $visitormail\n
Phone Number: $visitortel\n
Bookkeeping/Payroll: $bp\n
Number of Transactions: $transcations\n
Number Of Employees: $employees\n
Payroll Weekly/Monthly: $pmw\n"
;
$subject = "Payment Details";
mail("contact@email.com",$subject,$message,$visitormail);
?>
<p align="center">
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
<br />
<a href="home.php">Click here to Finish</a>
</p>
答案 0 :(得分:3)
<h2 class="green">Interested in making life easier?</h2>
<form method="post" action="sendemail.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<table>
<tr>
<td><label for="visitor">Name:</label></td>
<td><input type="text" name="visitor" size="25" /></td>
</tr>
<tr>
<td><label for="visitoradd">Address:</label></td>
<td><input type="text" name="visitoradd" size="25" /></td>
</tr>
<tr>
<td><label for="visitorcity">City:</label></td>
<td><input type="text" name="visitorcity" size="15" /></td>
</tr>
<tr>
<td><label for="visitorpost">Postcode:</label></td>
<td><input type="text" name="visitorpost" size="15" /></td>
</tr>
<tr>
<td><label for="visitormail">E-mail:</label></td>
<td><input type="text" name="visitormail" size="25" /></td>
</tr>
<tr>
<td><label for="visitortel">Telephone Number:</label></td>
<td><input type="text" name="visitortel" size="25" /></td>
</tr>
<tr>
<td><label for="bp">Bookkeeping/Payroll:</label></td>
<td>
<select name="bp" size="1">
<option value=" Bookkeeping">Bookkeeping </option>
<option value=" Payroll ">Payroll</option>
</select>
</td>
</tr>
<tr>
<td><label for="transcations">Number of transactions:</label></td>
<td><input type="text" name="transcations" size="15" /></td>
</tr>
<tr>
<td><label for="employees">Number of employees:</label></td>
<td><input type="text" name="employees" size="15" /></td>
</tr>
<tr>
<td><label for="pmw">Payroll weekly/monthly:</label></td>
<td>
<select name="pmw" size="1">
<option value=" Weekly">Weekly</option>
<option value=" Monthly">Monthly</option>
</select>
</td>
</tr>
</table>
<br />
<INPUT TYPE="image" SRC="images/btnSubmit.png" ALT="Submit Form">
<br />
</form>
答案 1 :(得分:2)
将表单标记放在表格之外,如下所示:
<form>
<TABLE>
<TR>
<TD>Name</TD>
<TD><input type="text" name="visitor" size="25" /></TD>
</TR>
<TR>
<TD>Address</TD>
<TD><input type="text" name="address" size="25" /></TD>
</TR>
</TABLE>
</form>
如果您需要指定宽度,高度等,请使用CSS。
这是一个很棒的教程:http://www.w3schools.com/css/