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. Quote Link to comment Share on other sites More sharing options...
revraz Posted March 19, 2008 Share Posted March 19, 2008 Indicates a problem with your form Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 . Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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'] Quote Link to comment 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'. Quote Link to comment 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!! Quote Link to comment 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.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.