searls03 Posted May 17, 2011 Share Posted May 17, 2011 is there a reason why this code is making my username.......searls03 and password as default value for the email and password fields? <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $username = $row["username"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; } // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['Submit'])){ $name = "{$_POST['fname']}{$_POST['last']}"; $fname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['fname']); $lname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['lname']); // filter everything but numbers and letters $phone = ereg_replace("[^A-Z a-z0-9]", "", $_POST['phone']); // filter everything but spaces, numbers, and letters $username = ereg_replace("[^A-Z a-z0-9]", "", $_POST['username']); // filter everything but spaces, numbers, and letters $address = ereg_replace("[^A-Z a-z0-9]", "", $_POST['address']); // filter everything but spaces, numbers, and letters $city = ereg_replace("[^A-Za-z0-9]", "", $_POST['city']); // filter everything but lowercase letters $state = ereg_replace("[^A-Za-z0-9]", "", $_POST['state']); // filter everything but lowercase letters $zip = ereg_replace("[^A-Za-z0-9]", "", $_POST['zip']); // filter everything but lowercase letters $cell = ereg_replace("[^A-Za-z0-9]", "", $_POST['cell']); // filter everything but lowercase letters $accounttype = ereg_replace("[^A-Z a-z0-9]", "", $_POST['accounttype']); // filter everything but lowercase letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters // Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if( (!$username) || (!$password)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$fname){ $errorMsg .= "--- Name"; } else if(!$username){ $errorMsg .= "--- Username"; } else if(!$Password){ $errorMsg .= "--- Password"; } } else { // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT userid FROM members WHERE username='$username' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); if ($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another."; } else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = "INSERT INTO members (First, Last, name, phone, username, address, city, state, zip, cell, email, accounttype, password, password2) VALUES('$fname', '$lname','$name','$phone','$username','$address','$city','$state','$zip','$cell','$email','$accounttype','$hashedPass', '$password')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); echo mysql_error(); $sql = "INSERT INTO sessions ( username, accounttype, password, password2 ) VALUES('$username','$accounttype','$hashedPass', '$password')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); echo mysql_error(); echo '<meta HTTP-EQUIV="REFRESH" content="0; url=success.php">'; exit(); // Exit so the form and page does not display, just this success message } // Close else after database duplicate field value checks } // Close else after missing vars check //Close if $_POST } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template2.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>New Member---Boy Scout Troop 78</title> <!-- InstanceEndEditable --> <style type="text/css"> body { background-image: url(button/boyscout1.png); background-repeat: no-repeat; position: relative; } #menu { position:relative; left:160px; top:0px; width:931px; height:59px; z-index:19; } #menu #MenuBar1 li a { color: #000; border-top-style: outset; border-right-style: outset; border-bottom-style: outset; border-left-style: outset; width: 100px; } #status { position:relative; left:16px; top:180px; width:124px; height:44px; z-index:14; } </style> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> <!-- InstanceBeginEditable name="head" --> <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script> <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" /> <!-- InstanceEndEditable --> <!-- InstanceParam name="id" type="text" value="apDiv6" --> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #logout { position:relative; left:0px; top:0pxpx; width:134px; height:38px; z-index:20; font-weight: bold; font-size: 24px; } #logout a { color: #000; } #status { text-align: center; } #logout1 { position:absolute; left:1071px; top:191px; width:224px; height:61px; z-index:2; } #menu2 { position:absolute; left:-1px; top:172px; width:497px; height:92px; z-index:20; } * { padding: 0; } html, body { height: 100%; } .wrapper { min-height: 100%; height: auto !important; height: 100%; padding: 0 auto -4em; } .footer, .push { height: 4em; clear: both; } </style> </head> <body> <div id="menu2"><div id="menu"> <ul id="MenuBar1" class="MenuBarHorizontal"> <li><a href="myprofile.php">My Profile</a> </li> <li><a href="register.php">Register</a></li> <li><a href="dashboard.php">Dashboard</a> </li> <li><a href="news.php">News</a></li> <?php if ($accounttype == "Admin") { ?> <li><a href="membermanager.php">Scout Manager</a></li> <li><a href="eventmanager.php">Event Manager</a></li> <li><a href="newsmanager.php">News Manager</a></li> </ul><?php } ?><?php if ($accounttype == "Scout Master") { ?> <li><a href="membermanager.php">Scout Manager</a></li> <li><a href="eventmanager.php">Event Manager</a></li> <li><a href="newsmanager.php">News Manager</a></li> </ul><?php } ?> </div></div> <div id="logout1"><div id="logout"><a href="logout.php">Logout</a></div></div> <div id="status"><?php echo "$accounttype"; ?> <br /><?php echo "$name"; ?> <p> </p> </div><br /><br /><br /><br /><br /><br /><br /><br /><br /> <br /> <br /> <!-- InstanceBeginEditable name="EditRegion3" --> <div id="TabbedPanels1" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"> <li class="TabbedPanelsTab" tabindex="0">My Info</li> <li class="TabbedPanelsTab" tabindex="0">Scout Info</li> </ul> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent"><table width="600" align="center" cellpadding="4"> <tr> <td width="7%">Register new members here</td> </tr> </table> <table width="600" align="center" cellpadding="5"> <form action="join_form.php" method="post" enctype="multipart/form-data" > <tr> <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> </tr> <tr> <td width="163"><div align="right">First Name:</div></td> <td width="409"><div align="left"><input name="fname" type="text" /></div></td> </tr> <tr> <td width="163"><div align="right">Last Name:</div></td> <td width="409"><div align="left"><input name="lname" type="text" /></div></td> </tr> <tr> <td width="163"><div align="right">Phone:</div></td> <td width="409"><div align="left"><input name="phone" type="text" /></div></td> </tr> <tr> <td><div align="right">User Name: </div></td> <td><div align="left"><input name="username" type="text" /></div></td> </tr> <tr> <td><div align="right">Address: </div></td> <td> <div align="left"><input name="address" type="text" /></div> </td> </tr> <tr> <td><div align="right">City: </div></td> <td> <div align="left"> <input name="city" type="text" /></div> </td> </tr> <tr> <td><div align="right">State: </div></td> <td><div align="left"><input name="state" type="text" /></div></td> </tr> <tr> <td><div align="right">Zip Code: </div></td> <td><div align="left"><input name="zip" type="text" /></div></td> </tr> <tr> <td><div align="right">Cell Phone: </div></td> <td><div align="left"><input name="cell" type="text" /></div></td> </tr> <tr> <td><div align="right">Access Level: </div></td> <td><div align="left"><select name="accounttype" id="accounttype"> <option value="Scout" selected="selected">Scout</option> <option value="Scout Master">Scout Master</option> <option value="Admin">Admin</option> </select></div></td> </tr> </tr> <tr> <td><div align="right">Email Address: </div></td> <td><div align="left"><input name="email" type="text" /></div></td> </tr> <tr> <td><div align="right"> Password: </div></td> <td><div align="left"><input name="password" type="password" value="" /> </div> <font size="-2" color="#006600">(letters or numbers only, no spaces no symbols)</font></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table></div> <div class="TabbedPanelsContent"> Please create member profile for Scout Info. </div> </div> </div> <script type="text/javascript"> var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1"); </script> <!-- InstanceEndEditable --> <div class="push"></div></div> <div class="footer"><?php if($accounttype == "Admin"){include_once "footer-ad.php";}else if($accounttype == "Scout Master"){ include_once "footer-ad.php";} else if($accounttype == "Scout") { include_once "footer-sc.php"; } ?> </div> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"}); </script> </body> <!-- InstanceEnd --></html> Quote Link to comment https://forums.phpfreaks.com/topic/236598-strange-default-value/ Share on other sites More sharing options...
Psycho Posted May 17, 2011 Share Posted May 17, 2011 What do you mean "this code is making my username.......searls03 and password as default value"? I have no clue where in that long set of code where you are stating that is happening. Are one of the messages in the code stating something in particular? Can you point out the line in question where you are getting the unexpected results? That would help to trace back at where the error could be occuring? Quote Link to comment https://forums.phpfreaks.com/topic/236598-strange-default-value/#findComment-1216325 Share on other sites More sharing options...
searls03 Posted May 17, 2011 Author Share Posted May 17, 2011 well, I don't know where the problem would be at either. in the email piece of the form, it displays searls03 and in the password field it displays ******. I don't really know how to describe it better. i attached a picture of what it is doing. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/236598-strange-default-value/#findComment-1216326 Share on other sites More sharing options...
jcbones Posted May 17, 2011 Share Posted May 17, 2011 Did you save the username and password in your browser password manager? Quote Link to comment https://forums.phpfreaks.com/topic/236598-strange-default-value/#findComment-1216329 Share on other sites More sharing options...
searls03 Posted May 17, 2011 Author Share Posted May 17, 2011 thats probably it, I did, although why is the username in the email field? when there is actually a username field? Quote Link to comment https://forums.phpfreaks.com/topic/236598-strange-default-value/#findComment-1216330 Share on other sites More sharing options...
Psycho Posted May 17, 2011 Share Posted May 17, 2011 thats probably it, I did, although why is the username in the email field? when there is actually a username field? Because it is the field directly before the password field. The browser doesn't "comprehend" the text on the page it only makes a logical determination on what the username/password fields are. The "username" field could just as likely be named "login" or just about anything else based upon the language of the person who developed the page. So, the browser is likely detecting the "password" TYPE field and selecting the immediately preceeding field as the username. If you had simply stated the fields were pre-populated with values when the page loads - THAT would have described the problem. Instead, your original post could have meant just about anything. Especially when the code posted is pulling values from the database (could have been pulling wrong values) and is saving data to the database (could be saving the wrong values). Quote Link to comment https://forums.phpfreaks.com/topic/236598-strange-default-value/#findComment-1216376 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.