halm1985 Posted September 19, 2007 Share Posted September 19, 2007 I have a little weired problem . A PHP function attached to a form produces wrong resutls when i perss ENTER insread of pressing the SUBMIT button by mouse ? How can that be solved ? Link to comment https://forums.phpfreaks.com/topic/69871-pressing-submit-vs-pressing-enter/ Share on other sites More sharing options...
xyn Posted September 19, 2007 Share Posted September 19, 2007 what problem? Link to comment https://forums.phpfreaks.com/topic/69871-pressing-submit-vs-pressing-enter/#findComment-350962 Share on other sites More sharing options...
jitesh Posted September 19, 2007 Share Posted September 19, 2007 If you have written a script onClick method of submit button. then place it to the form's onSubmit method. Link to comment https://forums.phpfreaks.com/topic/69871-pressing-submit-vs-pressing-enter/#findComment-350964 Share on other sites More sharing options...
halm1985 Posted September 19, 2007 Author Share Posted September 19, 2007 no .. it's just an ordinary form follwoing is a simplifcation of the story <?php function test() { if ( isset ($_POST['submit']) ) { $text = $_POST['text']; if ( !empty ($text) ) { echo $text; } else { echo "PLEASE ENTER TEXT"; } } else { echo "PLEASE SELECT"; } unset ($_POST['text']); unset ($_POST['submit']); if ( !isset ($_POST['submit']) && !isset ($_POST['text']) ) echo "OKKKKKKKKK"; } ?> <form id="form1" name="form1" method="post" action=""> <label> <input name="text" type="text" id="text" /> </label> <label> <input name="submit" type="submit" id="submit" value="Submit" /> </label> </form> <?php test($submit,$text) ?> Link to comment https://forums.phpfreaks.com/topic/69871-pressing-submit-vs-pressing-enter/#findComment-350968 Share on other sites More sharing options...
jitesh Posted September 19, 2007 Share Posted September 19, 2007 Remove if ( isset ($_POST['submit']) ) // If you press submit button then it will set Place if ( isset ($_POST['text']) and !empty($_POST['text'])) Link to comment https://forums.phpfreaks.com/topic/69871-pressing-submit-vs-pressing-enter/#findComment-350972 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.