Re: problem with submit button

From: Date: Fri, 16 May 2003 01:38:43 +0000
Subject: Re: problem with submit button
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147850@lists.php.net to get a copy of this message
on 16/05/03 1:28 PM, Riza Fahmi (riza.fahmi@myrealbox.com) wrote: > Hi all, > > I have a little problem here. Let say i have 1 page for login (have > 2 textbox, name and password, and submit button). And if user click > submit button, then go to 2nd page. In the 2nd page: > <? > if(isset($_POST['submit']) > { > print "Submit Button click"; > } > else > { > print "Submit Button not click"; > } > ?> > > the problem are, after user filled two textbox on login form, and > then user push ENTER on his/her keyboard, in 2nd page appear "Submit > Button not click". I want if they push ENTER, still appear "Submit > Button click". Can anyone help me for this problems? By the way, > thanks for the attention. UNTESTED: You could have a hidden field in the form 'submit' with a value of '1' or 'submit' (anything true)... if the user just hits enter, this value will be used... if the user clicks the button, the button value will *probably* (you'll have to test that) overwrite the first. <form ...> <input type='text' name='firstname' value='' /> <input type='text' name='surname' value='' /> <input type='hidden' name='submit' value='submit' /> <input type='submit' name='submit' value='submit' /> </form> On the other hand, why don't you just test for the post array? <? if($_POST) { // they must have submitted the form via enter or button } else { // they didn't } ?> Justin

« previous php.general (#147850) next »