[SOLVED] forms clearing when hitting enter
Moderator: General Moderators
[SOLVED] forms clearing when hitting enter
I have 2 forms on a site that when i hit enter clears the field and doesnt submit, any ideas what would cause this?
Last edited by irealms on Thu Nov 04, 2004 4:27 am, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
echo '<form method="post" action="index.php?page=ordersearch">';
echo '<table cellspacing="2" cellpadding="5" bgcolor="#000000" align="center">';
echo '<tr bgcolor="#FFFFFF">';
echo '<td><b>Enter order number</b></td><td><input type"text" name="search" size="10"></td>';
echo '</tr>';
echo '<tr bgcolor="#FFFFFF">';
echo '<td colspan="2">';
echo '<input type="submit" name="searchorders" value="search">';
echo '</td>';
echo '</tr></table>';
echo '</form>';
?>no need to do all that, just make sure each submit has a unique name
Code: Select all
<form method="post">
<input type="submit" name="form1" />
</form>
<form method="post">
<input type="submit" name="form2" />
</form>Code: Select all
<?php
if (isset($_POST['form1'])) {
// handle form1 post
} else if (isset($_POST['form2'])) {
// handle form2 post
}
?>hmm thanks for doing that test phpscott, i'm confused too. I've used loads of forms before and not had the problem, really can't see where it's coming from.
I've also run that test now and it works in a blank page. I changed the page variable from ordersearch to something else and it redirects, then tried it as normal.
When hitting enter it seems to direct where it should but the code that recognises that submit has been sent isn't working, i am just using.
if (isset($_POST['searchorders']))
Which works find if i hit the button myself.
I've also run that test now and it works in a blank page. I changed the page variable from ordersearch to something else and it redirects, then tried it as normal.
When hitting enter it seems to direct where it should but the code that recognises that submit has been sent isn't working, i am just using.
if (isset($_POST['searchorders']))
Which works find if i hit the button myself.