Re: weird behavior with a form

From: Date: Sat, 04 Aug 2001 00:44:58 +0000
Subject: Re: weird behavior with a form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61211@lists.php.net to get a copy of this message
Ahh I see, ok yeah what Queen said is basically where the problem lies. I had this problem on one of my scripts. If you just hit enter without using the mouse to submit a form the buttons value does not get added onto the form. What I did to remedy this was included a hidden field and then do your checking on that field. Thanks for the clarification :) Rick > 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:rickbaskett@home.com] > Sent: Friday, August 03, 2001 5:31 PM > To: Benjamin Bleything; php-general@lists.php.net > 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> >> <title>Add Genre</title> >> <link rel="stylesheet" href="<?php echo $STYLESHEET; ?>" > type="text/css"> >> <script language="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> >> <h1>Add Genre</h1> >> <hr> >> <form method="post" action="addgenre.php" onSubmit="return >> verify()"> >> >> <table> >> >> <tr> >> <td>Name: </td> >> <td><input type="text" name="name" size="20" >> maxlength="50"></td> >> </tr> >> >> <tr> >> <td><input type="submit" name="submit" value="Add >> Genre"></td> >> <td><input 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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#61211) next »