I have a form where I am using an image as the submit button. When I click on the button the form submits however when I press 'enter' the page simply refreshes.

In my PHP code I use the submitok_x value to check the x co-ordinate value - if it is bigger than 0 (this means the image/button has been hit)

I have tried javascript to submit the form - but how in my PHP can I check if the form is been submitted by pressing 'eneter';

please help, thank-you :)


PHP ----
if ($_POST['submitok_x'] > 0)
//....this is at the top of my page and if true creates a session + redirects user


if($_POST['submitok_x'] < 1) 

<table width="100%" height="220" border="0" cellspacing="2">
    <td><div align="center">
      <form name="myform" action="login.php" method="post">
	  <table border="0" cellpadding="2" cellspacing="0">
          <td align="left" class="text style1"><b>Email</b>:</td>
          <td><input type="text" value='<? echo"$_GET[usr]";?>' name='uid' class="formborder" size="30" /></td>
          <td align="left" class="style2"><b>Password</b>:</td>
          <td><input type="password" name="pwd" class="formborder" size="30" /></td>
          <td colspan="2" align="right"><br />
		 <input type="image" name="submitok" src="images/button_go1.gif" alt="Go"/></td>
else // if username or password incorrect....access denied


ok I got it all working - stupid mishaps in my php code....

thanks anyway

my code is very messy....

all I did was put in further checks in my if statement:

if($_POST['submitok_x'] < 1 [B]|| $_POST[''] !=  '' .....[/B])) 


Nice of you...
This question has already been answered. Start a new discussion instead.