QuickOldCar Posted July 15, 2011 Share Posted July 15, 2011 show the users.php file you made, you can't output anything before a header redirect. as for the duplicate entry, that username is already registered in the database Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243143 Share on other sites More sharing options...
macfall Posted July 15, 2011 Author Share Posted July 15, 2011 show the users.php file you made, you can't output anything before a header redirect. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Fledge Press - Login</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <link rel="stylesheet" type="text/css" href="/fledge_styles.css"> <style type="text/css"> </style> </head> <body> <?php include("nav_ads.php"); ?> <div id="main"> <h4>Login:</h4> <?php include("login.php"); ?> <h4>Or register a new account:</h4> <?php include("register.php"); ?> <h4>Why register?</h4> <p>Registry is required in order for you to access downloadable content. It doesn't cost you anything - unless you want to become a supporter!</p> </div> <?php include("bottom.php"); ?> </body> </html> as for the duplicate entry, that username is already registered in the database I deleted the row in phpMyAdmin and tried again, and still got the same error. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243254 Share on other sites More sharing options...
QuickOldCar Posted July 15, 2011 Share Posted July 15, 2011 your ads outputs data, so must not be first, in register and also login there are header redirects you are also including both login and register in the same form place href links to them instead, thats the way it's set up and to do redirections <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Fledge Press - Login</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <link rel="stylesheet" type="text/css" href="/fledge_styles.css"> <style type="text/css"> </style> </head> <body> <?php include("nav_ads.php"); ?> <div id="main"> <h4><a href="login.php">Login</a></h4> <h4>Or <a href="register.php">Register</a> a new account:</h4> <h4>Why register?</h4> <p>Registry is required in order for you to access downloadable content. It doesn't cost you anything - unless you want to become a supporter!</p> </div> <?php include("bottom.php"); ?> </body> Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243268 Share on other sites More sharing options...
macfall Posted July 15, 2011 Author Share Posted July 15, 2011 Ok, I did that and it seems to have cleared up that issue. But I'm still getting this whenever I try to log in: "Duplicate entry 'macfall' for key 'username'" And that's after I deleted ALL the rows from the table and started again. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243297 Share on other sites More sharing options...
macfall Posted July 16, 2011 Author Share Posted July 16, 2011 Update: register.php works fine. Login, however, keeps returning an "invalid login" error. I've checked half a dozen times to make sure I'm putting in the same information. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243309 Share on other sites More sharing options...
QuickOldCar Posted July 16, 2011 Share Posted July 16, 2011 As a note..if you want the login to be on another page..you can just make a form that leads to the login page. Now as for your problem. Are you using all of these exact files in this post? http://www.phpfreaks.com/forums/index.php?topic=338735.msg1596372#msg1596372 the others were different Did you drop the table and create a new one with these values? CREATE TABLE dbUsers ( id int NOT NULL AUTO_INCREMENT, username varchar(32) Unique, password char(32), email varchar(32), PRIMARY KEY (id) ) I assure you everything works as expected, besides better error messages on a few items. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243310 Share on other sites More sharing options...
macfall Posted July 16, 2011 Author Share Posted July 16, 2011 Should "username", "password", and "email" be null? Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243312 Share on other sites More sharing options...
macfall Posted July 16, 2011 Author Share Posted July 16, 2011 I have everything copied EXACTLY. I'm still getting "Invalid Login" whenever I try to log in with credentials I just entered in the registry form. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243317 Share on other sites More sharing options...
jcbones Posted July 16, 2011 Share Posted July 16, 2011 Make sure there are no spaces before you opening <?php tag. That should take care of the header error. The other is because the db table's username column is set to a unique key. Which means it will only store a username IF it doesn't already exist. This is a good thing, because you don't want two people with the same name. If that error shows up, then it is because the database is working correctly. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243321 Share on other sites More sharing options...
QuickOldCar Posted July 16, 2011 Share Posted July 16, 2011 CREATE TABLE IF NOT EXISTS `dbusers` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) collate utf8_unicode_ci default NULL, `password` char(32) collate utf8_unicode_ci default NULL, `email` varchar(32) collate utf8_unicode_ci default NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243322 Share on other sites More sharing options...
macfall Posted July 16, 2011 Author Share Posted July 16, 2011 Make sure there are no spaces before you opening <?php tag. That should take care of the header error. The other is because the db table's username column is set to a unique key. Which means it will only store a username IF it doesn't already exist. This is a good thing, because you don't want two people with the same name. If that error shows up, then it is because the database is working correctly. "Invalid login" is not the error for duplicate data, is it? And I'm getting it when I submit login information, not registry information. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243323 Share on other sites More sharing options...
QuickOldCar Posted July 16, 2011 Share Posted July 16, 2011 it is, there wasn't much for error checking Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243325 Share on other sites More sharing options...
jcbones Posted July 16, 2011 Share Posted July 16, 2011 Make sure there are no spaces before you opening <?php tag. That should take care of the header error. The other is because the db table's username column is set to a unique key. Which means it will only store a username IF it doesn't already exist. This is a good thing, because you don't want two people with the same name. If that error shows up, then it is because the database is working correctly. "Invalid login" is not the error for duplicate data, is it? And I'm getting it when I submit login information, not registry information. Sorry, X out my whole post, as I didn't see "page 2". Oh, the eyes are getting to old. Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243326 Share on other sites More sharing options...
QuickOldCar Posted July 16, 2011 Share Posted July 16, 2011 Although I feel this is an ok registration system if wanted to add custom items to it, but still lacking many features. You could try this one perhaps using jquery http://tutorialzine.com/2009/10/cool-login-system-php-jquery/ Quote Link to comment https://forums.phpfreaks.com/topic/242033-code-from-phpmysql-tutorial-doesnt-work/page/2/#findComment-1243327 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.