问题
Ok here is what I got, I have a web site that is built in html,css,JS. I also have a form on the contact us page, below is the code for the form. Also with this I have a php form validation with a honeypot on it. When I submit the form, if done in 7sec or less it wont submit the form. The time can be adjusted to page loading. The issue I am having is when the submit button is clicked, it goes to a 404 page. I feel the issue is in me action of the form but I am not 100% sure. Any help would be great to understand what is going on here. Thanks
<div class="col1 pad_left1">
<h2>Contact Form</h2>
<form method="post" action="<? $_SERVER['PHP_SELF']?>">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr valign="top">
<td width="20%">
<label for="name">Name:</label>
</td>
<td>
<input name="name" type="text" size="40" maxlength="60" id="name" >
</td>
</tr>
<tr valign="top">
<td>
<label for="hotel">Hotel/Company:</label>
</td>
<td>
<input name="hotel" type="text" size="40" maxlength="60" id="hotel" >
</td>
</tr>
<tr valign="top">
<td>
<label for="address">Address:</label>
</td>
<td>
<input name="hotel" type="text" size="40" maxlength="100" id="address" >
</td>
</tr>
<tr valign="top">
<td>
<label for="state">City/State:</label>
</td>
<td>
<input name="state" type="text" size="40" maxlength="100" id="state" >
</td>
<tr valign="top">
<td>
<label for="email">Email Address:</label>
</td>
<td>
<input name="email" type="email" size="40" maxlength="60" id="email" >
</td>
</tr>
<tr valign="top">
<td>
<label for="phone">Phone:</label>
</td>
<td>
<input name="phone" type="text" size="40" maxlength="100" id="phone" >
</td>
<tr valign="top">
<td>
<label for="comments">Comments:</label>
</td>
<td>
<textarea name="comments" rows="10" cols="50" id="comments"></textarea>
</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<div>
<input type="hidden" name="loadtime" value="<?php echo time(); ?>">
</div>
<input type="submit" name="Submit" value="Submit">
<input name="Reset" type="reset" id="Reset" value="Reset">
</div></td>
</tr>
</table>
</form>
回答1:
You're not actually echoing anything out in the action, so it will post to itself - which might be where the 404 is coming from?
Change it to:
<?=$_SERVER['PHP_SELF']?>
Note the = sign, this will echo the content on the page.
来源:https://stackoverflow.com/questions/20639076/html-form-with-php-validation-and-honeypot