boblan66 Posted November 8, 2010 Share Posted November 8, 2010 I creating a members only web for my wife's 45th reunion. Everything went great untill I tackled something I never did before. PHP! From the home page I'm having the user enter a username and password. I created the db using phpmyadmin and populated the table with two users. I checked the include and it is attempting to open the db and proper table. however, the php loginck.php, goes to the programed error message. Can I get a little assistance, it would be greatly appreciated. The form calls loginck,pfp and it gets there OK. <div class="art-blockcontent"> <div class="art-blockcontent-body"> <!-- block-content --> <div style="border: medium ridge blue;padding:15px; font-size:.8em;"> To assist in maintaining contact with our alumni, please register. <br> Already registered, sign in. <br><br> <form action="loginck.php" method="POST"> <label>Username: </label><input type="varchar" style="height: 1em;" size="15" name="passWord" required> <br> <label>Password: </label><input type="password" style="height: 1em;" size="15" name="passWord" required> <br><br> <center><input type="submit" value="Sign In"> <input type="reset" value="Clear"></center> </form> <br><br> <a href="register.html">Register</a> <br> <hr> <br> This site best viewed using Google Chrome, FireFox, or Opera browsers. </form> </div> <!-- /block-content --> I attached loginck.php and the inserted a called file 'z_db.php' for your review. I know if I can get this figured out I can do the others I need to do. Sorry, if ther's too many typos, I'm relegated to typing with one finger (Stroke) and in a wheel chair. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/218083-problem-with-mysql-db/ Share on other sites More sharing options...
OldWest Posted November 8, 2010 Share Posted November 8, 2010 Hey Brother! Man. You really need to get a basic book or read some fundamental tutorials on php and MySQL... I am not saying this to be anal, but to try to get your some real help... Just at a glance, without even looking at your attached files, I am wondering why your <input /> fields have the same name. And although type="varchar" might exist in html (i've never used it and not aware of it ever existing), I think you're better of with type="text". I think you would be better off having your hosting company install a script like Joomla, and you can manage everything from that CMS without getting involved in the programming.. - just my 2cents. Link to comment https://forums.phpfreaks.com/topic/218083-problem-with-mysql-db/#findComment-1131675 Share on other sites More sharing options...
pengu Posted November 8, 2010 Share Posted November 8, 2010 As said above. Names are wrong. Keep in mind you're uploading your files to a PUBLIC forum. You should ALWAYS ALWAYS, change your usernames/passwords in files you upload. <label>Username: </label><input type="text" style="height: 1em;" size="15" name="username" required> <--! this should be username.. not password --> <br> <label>Password: </label><input type="password" style="height: 1em;" size="15" name="passWord" required> Link to comment https://forums.phpfreaks.com/topic/218083-problem-with-mysql-db/#findComment-1131678 Share on other sites More sharing options...
Buddski Posted November 8, 2010 Share Posted November 8, 2010 To make the form function with the backend PHP, as stated above, you need to change your username field name to "userName" I have had a quick look at your PHP code and found this line to be redundant if(($rec['userName']==$userName)&&($rec['passWord']==$passWord)){ as the SQL is only getting rows that have the username and password that was submitted via the form. Something like this would be more appropriate. $sql_query = mysql_query("SELECT * FROM `signup` WHERE `userName`='$userName' AND `passWord` = '$passWord' LIMIT 1"); if (mysql_num_rows($sql_query) > 0) { // RUN YOUR WELCOME SCRIPT } else { // RUN YOUR ERROR MESSAGE } Hope this helps. Link to comment https://forums.phpfreaks.com/topic/218083-problem-with-mysql-db/#findComment-1131687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.