aebstract Posted March 19, 2008 Share Posted March 19, 2008 <?php if(isset($_SESSION["id"])) { header("Location: /accounthome/"); exit(); } //Doesn't this happen in the include('connect.php') in index.php? mysql_connect("localhost","berryequipment","gU8Kso8Y") or die(mysql_error()); mysql_select_db("berryequipment_net_db"); if(isset($_POST['submit'])) { if(empty($_POST['password'])) { $error .= 'You must fill in a password <br />'; } if(!strlen($error)) { $result = mysql_query("SELECT * FROM `users` WHERE `plant` = '".mysql_real_escape_string($_POST['dropdown'])."' AND `password` = '".md5($_POST['password'])."'") or die("Query error: ".mysql_error()); if(mysql_num_rows($result) == 0) { $error .= "The pasword you entered did not match the plant location you chose."; } else { $worked = mysql_fetch_array($result); $_SESSION["id"] = $worked['plant']; header("Location: /accounthome/"); exit; } } } $content .= '<center><table><tr><td><form action="/login/" method="post">Location: </td><td><select name="dropdown">'; $result = mysql_query("SELECT * FROM `plants` ORDER BY `plantloc` ASC") or DIE(mysql_error()); while($r = mysql_fetch_array($result)) { $id = $r['id']; $plantloc = $r['plantloc']; $content .= "<option value=\"{$id}\">{$plantloc}</option>\n"; } $content .= '</select></td></tr><tr><td> Password: </td><td> <input type="password" name="password" size="6" /> </td></tr><tr><td></td><td> <input type="submit" name="submit" value="login" /> </td></tr></table></center></form>'; ?> Okay, here is the problem I am having: If you're on internet explorer and fill out your password and hit enter, it just reloads the page.. Firefox will submit the form and log you in. Is this a problem with the php, just the form or something else? I am not sure and it is a problem because a lot of people like to just push enter after inserting their passwords! Please help, and thank you. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/ Share on other sites More sharing options...
revraz Posted March 19, 2008 Share Posted March 19, 2008 Indicates a problem with your form Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-495808 Share on other sites More sharing options...
aebstract Posted March 19, 2008 Author Share Posted March 19, 2008 Well looking at the code, could it be the way the dropdown is generated or something? What kind of problem causes this? Possible because of the table it is in? Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-495809 Share on other sites More sharing options...
thebadbad Posted March 19, 2008 Share Posted March 19, 2008 Sort out your HTML. For one, you're closing the form tag the wrong place. Edit: More like you're opening it the wrong place Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-495824 Share on other sites More sharing options...
aebstract Posted March 19, 2008 Author Share Posted March 19, 2008 How is it "wrong"? I was unaware that there was an actual correct spot to start a form, which may easily be causing the problem. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-495827 Share on other sites More sharing options...
thebadbad Posted March 19, 2008 Share Posted March 19, 2008 It's wrong in relation to some of your other tags: Wrong way (kinda the way you are doing it): <table><tr><td><form></td></tr></table></form> Right way: <form><table><tr><td></td></tr></table></form> You know, tags mustn't overlap each other. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-495835 Share on other sites More sharing options...
aebstract Posted March 19, 2008 Author Share Posted March 19, 2008 Oh, well I tried to put the form opening tag outside of the table and didn't work, also tried to put the closing tag inside of the table and that didn't work. Thinking it isn't because of that overlay. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-495838 Share on other sites More sharing options...
Braveheartt Posted March 19, 2008 Share Posted March 19, 2008 if(isset($_POST['submit'])) To make enter work, remove that line of code. That line means "if the button 'submit' is pressed, continue" pressing enter is not pressing that button . Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496003 Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 i suggest if ($_SERVER['REQUEST_METHOD'] == "POST") instead. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496004 Share on other sites More sharing options...
thebadbad Posted March 19, 2008 Share Posted March 19, 2008 if(isset($_POST['submit'])) To make enter work, remove that line of code. That line means "if the button 'submit' is pressed, continue" pressing enter is not pressing that button . No, that's not true. $_POST['submit'] is simply present if the form has been submitted, no matter how it was done. To OP: I see you use a lot of javascript for the site, does any of it apply to the form? If not, test your form starting from scratch, and see if it works. Then add on code as long as it's still working, and you'll eventually find the error. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496228 Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 No, that's not true. $_POST['submit'] is simply present if the form has been submitted, no matter how it was done. No, THAT is incorrect. If you have no form element with name='submit', $_POST['submit'] will be empty. try this: <? $username = "user"; $password = "password"; if ($_POST['submit']) { die ("form was posted"); } ?> <h4>Login Below:</h4> <div class="detailTextGrey"> <!-- Login Form --> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> User Name: <input type="text" name="loginUserName"> Password: <input type="password" name="loginPassword"> <input type="submit" value="test" name='test'> </form> to be certain that a form was submitted either check $_SERVER['REQUEST_METHOD'] or look for a specific $_POST value. I prefer to go straightforward with $_SERVER['REQUEST_METHOD'] Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496237 Share on other sites More sharing options...
thebadbad Posted March 19, 2008 Share Posted March 19, 2008 No, in this case I'm right, because his form has that element. I said 'the form', not 'a form'. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496260 Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 you are absolutely correct. i thought you meant that $_POST['submit'] is always set for a POSTed form. My apologies!! Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496262 Share on other sites More sharing options...
thebadbad Posted March 19, 2008 Share Posted March 19, 2008 Don't apologize, I could have been more clear At least people should be certain about it now.. Link to comment https://forums.phpfreaks.com/topic/96892-enter-wont-submit-form/#findComment-496267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.