Re: [PHP] weird behavior with a form
If they didn't click on the submit button, then they didn't click on the submit button, and it's not set by the browser. Check if the variable you care about inserting is set instead. -- WARNING [EMAIL PROTECTED] address is an endangered species -- Use [EMAIL PROTECTED] Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm - Original Message - From: Ben Bleything [EMAIL PROTECTED] Newsgroups: php.general To: 'Richard Baskett' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, August 03, 2001 7:25 PM Subject: RE: [PHP] weird behavior with a form Perhaps a little clarification... I'm very sorry I wasn't clear in the first place! = The page works fine if I click on submit with the mouse. I'm curious why it doesn't when the user presses their 'Enter' key while the text field is focused. They will be entering piles of info, just trying to make it more convenient = Thanks again, Ben -Original Message- From: Richard Baskett [mailto:[EMAIL PROTECTED]] Sent: Friday, August 03, 2001 5:31 PM To: Benjamin Bleything; [EMAIL PROTECTED] Subject: Re: [PHP] weird behavior with a form Try using this INSERT statement: $query = INSERT INTO genres (name) VALUES ('$name'); I subtracted one of the ;, I dont think you need it when running a query from php. Let's see.. what else.. hmm.. actually that's all I can see. Hopefully that does it. If not I hope someone else answers :) Rick Okay... so this is sorta off topic... but the form is generated by a script = Anyway, for some reason, when I fill in a form on my site and press enter, it doesn't actually submit the form and do the processing like it is supposed to... it should be throwing some information into the database. Instead, it seems to just be reloading the page. Source is below... if anybody has any idea, I would appreciate... I imagine I'm just doing something stupid wrong. Thanks, Ben --- SOURCE --- ?php include_once(../include/definitions.inc); include_once(../include/functions.inc); // Check to make sure they're allowed to be here session_start(); check_access($session_data); // They haven't clicked anything, so show the form if(!$submit) { ? html head titleAdd Genre/title link rel=stylesheet href=?php echo $STYLESHEET; ? type=text/css scriptlanguage=javascript function verify() { if(document.forms[0].name.value==) { alert(The name field cannot be blank!); return false; } return true; // fallthrough } /script /head body center h1AddGenre/h1 hr form method=post action=addgenre.php onSubmit=return verify() table tr tdName: /td tdinput type=text name=name size=20 maxlength=50/td /tr tr tdinput type=submit name=submit value=Add Genre/td tdinput type=reset/td /tr /table /form ?php include ../include/footer.php; ? /body /html ?php } else { setup_db_connection('w') or die(Could not connect to database!); file://Stick it in $query = INSERT INTO genres (name) VALUES ('$name');; mysql_query($query); header(Location: genres.php); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] weird behavior with a form
on 8/3/01 6:43 PM, Ben Bleything at [EMAIL PROTECTED] wrote: Whacky. It works now = i seem to remember a thread not that long ago (maybe it was on a different list) similar to this. the conclusion was that netscape and ie (and i'm sure others as well) handle this differently, and one of them (i can't remember which) handles it differently if there is more than one button on the page. i think if the browser is ie and there is only one submit button, hitting enter also returns submit='whatever'. otherwise, no guarantees. it appears that hiddens are the way to go -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] weird behavior with a form
Submit should get set when you click the submit button... it is not used anywhere else... Again, it works when you click the button, just not when you press enter... = I'm going to try what Richard just suggested, and I'll get back to you. Ben -Original Message- From: Queen [mailto:[EMAIL PROTECTED]] Sent: Friday, August 03, 2001 5:31 PM To: Benjamin Bleything Cc: [EMAIL PROTECTED] Subject: Re: [PHP] weird behavior with a form On Fri, 3 Aug 2001, Benjamin Bleything wrote: Date: Fri, 3 Aug 2001 17:05:54 -0700 (PDT) From: Benjamin Bleything [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP] weird behavior with a form Okay... so this is sorta off topic... but the form is generated by a script = Anyway, for some reason, when I fill in a form on my site and press enter, it doesn't actually submit the form and do the processing like it is supposed to... it should be throwing some information into the database. Instead, it seems to just be reloading the page. Source is below... if anybody has any idea, I would appreciate... I imagine I'm just doing something stupid wrong. Does $submit get unset in any of your include files? Does it get set at all? Can you acess $submit through $GLOBALS[$submit]? --- SOURCE --- ?php include_once(../include/definitions.inc); include_once(../include/functions.inc); // Check to make sure they're allowed to be here session_start(); check_access($session_data); // They haven't clicked anything, so show the form if(!$submit) { ? html head titleAdd Genre/title link rel=stylesheet href=?php echo $STYLESHEET; ? type=text/css scriptlanguage=javascript function verify() { if(document.forms[0].name.value==) { alert(The name field cannot be blank!); return false; } return true; // fallthrough } /script /head body center h1AddGenre/h1 hr form method=post action=addgenre.php onSubmit=return verify() table tr tdName: /td tdinput type=text name=name size=20 maxlength=50/td /tr tr tdinput type=submit name=submit value=Add Genre/td tdinput type=reset/td /tr /table /form ?php include ../include/footer.php; ? /body /html ?php } else { setup_db_connection('w') or die(Could not connect to database!); //Stick it in $query = INSERT INTO genres (name) VALUES ('$name');; mysql_query($query); header(Location: genres.php); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]