ckehrer Posted October 3, 2009 Share Posted October 3, 2009 Hi, Just a quick question. I'm working on a social_network site for a certification consisting of pages login, join, edit, profile ect. Below is code for the login page, but my problem is when the page is loaded the email and password fields on all pages instead of being blank are displaying my personal account email and password information. No ideas why this is happening. Any help would be appreciated. Thanks, Charlie <?php #login.php -- interface for logging into the social networking site #first, if a member's already logged in, redirect to the profile page. session_start(); if ($_SESSION['memberID']) { #if already logged in, redirect header("Location: /social/profile.php"); exit(); } else { if(count($_POST) > 0) { $host = "myhost"; //yourlogin should be your Sandbox login $user = "username"; $pw = "userpw"; $database = "database"; $table_1 = "member_login"; $db = mysql_connect($host,$user,$pw) or die("Cannot connect to mySQL."); mysql_select_db($database,$db) or die("Cannot connect to database."); $email = $_POST['email']; $password = $_POST['password']; #only check if someone has submitted an email or a password if ($email || $password) { #make sure both exist if (!($email)) { $error_message = "Please enter the email address you used to join. "; } else if (!($password)) { $error_message = "Please enter your password. "; } else { #now, check the database for a correct login $command = "SELECT memberID FROM $table_1 WHERE email='".addslashes($email)."' AND password=password('".addslashes($password)."');"; $result = mysql_query($command); if ($data = mysql_fetch_object($result)) { #correct login! Set cookie and redirect. $_SESSION['memberID'] = $data->memberID; header("Location: /social/profile.php"); } else { $error_message = "Sorry, your login was incorrect. Please contact us if you've forgotten your password."; } } } } #a nice-looking header include($_SERVER['DOCUMENT_ROOT']."/.php_files/social_header.inc"); ?> <h4>Log in to access your profile and connect to others!</h4> <span style="color:red;font-size:12px;"> <? if ($error_message) { echo $error_message; } ?> </span> <form method=POST action="/sql2_final/login.php"> <table> <tr> <td align=right> Email address: </td> <td align=left> <input type=text size=24 max=50 name="email" value="<? echo htmlentities($email); ?>"> </td> </tr> <tr> <td align=right> Password: </td><td align=left> <input type=password size=12 max=12 name="password" value=""> </td> </tr> <TR> <TD colspan=2 align=center> <input type=submit value="SUBMIT"> </TD></TR> </TABLE><br> Not a member? <a href="join.php">Click here</a> to join! </form> <?php } #a nice-looking footer include($_SERVER['DOCUMENT_ROOT']."/.php_files/social_footer.inc"); ?> Quote Link to comment Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 I'll be honest, I haven't even looked at your code. But from the description of the 'problem' it sounds like normal behaviour. Most browsers autofill email, username fields etc, and if asked to remember them will also fill in passwords. Quote Link to comment Share on other sites More sharing options...
ckehrer Posted October 3, 2009 Author Share Posted October 3, 2009 Thanks for the reply. Any ideas on how to fix this behavior? Quote Link to comment Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 You can't really fix it no, because it isn't broken , if you mean can you stop it then the answer is a little more murky. There have been a few threads on the forum recently (I've only been here a few days, so there's probably an awefully lot of them) asking this question. To my knowledge there is the non-standard autocomplete attribute <input type="text" autocomplete="off" />, but I don't believe it always works. I've got a feeling my banks site uses JavaScript to clear the box after the page has loaded, but obviously theres no guarantee the user has JavaScript enabled. I suggest tryin to search the forum and see what you can come up with. Quote Link to comment Share on other sites More sharing options...
ckehrer Posted October 7, 2009 Author Share Posted October 7, 2009 Thanks again for the help. Firefox was the culprit. If anyone ever has the same problem here is the fix: Preferences->Privacy->Uncheck Remember Search and Form History. Quote Link to comment Share on other sites More sharing options...
cags Posted October 7, 2009 Share Posted October 7, 2009 You should take note that most browsers implement this funcitonality in one way or another. 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.