PHP Login System Reloaded v1.1

Here’s an updated version of the PHP Login System. You can check the old version here. The following was added: 1. Registration fields: email confirmation password confirmation country recaptcha Email confirmation and password confirmation are configurable fields. By default they are shown, but if you wish to remove one or both of them you have […]

From our sponsor: Ship fast and never break a thing with Shortcut (formerly Clubhouse.io).


PHP Login System

Here’s an updated version of the PHP Login System. You can check the old version here.

The following was added:

1. Registration fields:

  • email confirmation
  • password confirmation
  • country
  • recaptcha

Email confirmation and password confirmation are configurable fields. By default they are shown, but if you wish to remove one or both of them you have to set it in the file constants.php:

define("REPEAT_EMAIL",true);
define("REPEAT_PASSWORD",true);

2. Table fields:

  • the user ip,
  • number of logins of a user,
  • flag is_admin
  • flag is_blocked
  • new table – Country table

3. dbcontroller class sanitizes user input data

4. Edit Account Area

5. Admin Area – incomplete (for next version)

For now just the list of users is shown and a world map indicating where the users come from.  You can delete Users and set them as Admins. If there are no users to list, no map is shown. Also the User seeing the panel is not shown.
Note that in the demo you will not be able to see the admin part – for admin reasons 🙂

6. New CSS

7. Some other small details in the php code.

For the next version I am planning to :

  • add all admin functions
  • improve and improve ….

To use the recaptcha you need to get a public/private key here . Then you need to define them in constants.php:

define("PUBLICKEY","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
define("PRIVATEKEY","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

In order to use the demo for those who have registered in the previous version’s demo, you need to register again (in the demo login system), since I had to set up another database for it.

Hope you like it. Any suggestions or improvements are welcome!

DEMO

Download the source code here

Tagged with:

chadking

Chadking is an absolute geek that rarely leaves the comfort of his 3-screen desk. He is a self taught programmer and is addicted to all possible legal drugs.

http://tympanus.net/codrops/author/chadking/

Stay up to date with the latest web design and development news and relevant updates from Codrops.

Feedback 287

Comments are closed.
  1. The code is really nice and thanks for sharing. I have a little problem with redirection to another page after I am logged in”if($objCore->getSessionInfo()->isLoggedIn())” . Does anyone know how to do it?

  2. Great login and registration system with clean and nice code.
    I’ve tested it in local server and its worked !
    Thanks Chad..

  3. Is there a way to configure the system to send out emails from a local host? I have tried to go through the registration on my local machine and send myself a confirmation email but have not been successful.

  4. Great secure login system!

    Should there be an option to resend the initial registration confirmation email incase it is deleted accidentally ?

    Whilst testing the script I managed block myself out by deleting the email confirmation.

    I can reset my password any number of times but I cannot login because I do not have the registration confirmation email and I cannot re-register because my email has already been registered.

  5. Can anyone tell me how can I add a new user so that I could test the system on my localhost? Is it enough to add manually a record to the database? However, it doesn’t seem to work.
    I will be grateful for any resonse!

  6. I have the system up and running but the confirm.php is not showing up after I click on the emailed link. I am getting a 404 page.
    I have tried changing around the ../ to ./ but no change.

    Also the hash is in the url and it should not be there. I have been trying to work out how to take that out.
    any help would be great.

  7. Your system is very good but i just want some pages to protect or you can say just few pages which are necessary for site admin for managing site crucial data and statistics.
    Which just need ONE id and pass or Few mod id and pass too.. can we accomplish this with this script if yes than how ?

  8. Hey Chadking
    Great script and a big improvement on jpmasters version.
    It works perfectly on my home windows php installation but when I upload it to my live linux server the registration page just hangs. I have checked sendmail with a testscript and this works fine so I am now stuck at this point, any ideas please?
    Note that the windows installation uses smtp if that gives any clues?
    Thanks
    Mike

  9. Registration hangs
    I believe I have the answer to the registration page problem, the error is from the recaptcha site, the solution is as follows:
    1) download the latest recaptcha files from their website and replace the old ones in this script
    2) edit the recaptcha.php pages and wherever you find an entry for ‘www.google.com’ replace this with the ip address of google

    Worked perfectly for me after this change so it must be some sort of dns error in the recaptcha system that holds up the whole registration process.

  10. Hey cool. I just uploaded and rigged the system. Been an interesting week.

    1. After upload, change the folders from 775 to 755. (Is that safe?) Fixes a number of install problems mentioned above.
    2. In public_index.php, add one level of directory and that seems to fix all the ../ problems mentioned above:
    <?php
    require_once("../(directory level)/php/core.php"); because this is the first time and after that all other references will be fine (you don't have to change ../ to ./) Am I making sense? I use a subdomain and a pointer.
    3. I changed the table from users to (my name)_users because I already had a users table for another application and didn't want to mess it up. Just copy and paste into a text editor and then search and replace all instances in the dbcontroller.php file. I think I counted 22 instances??
    4. I'm thinking I'll change the Country table to a table listing names of schools. My application is for teachers from a large number of schools and the country doesn't matter. Pretty easy to do. The table can still be called Country in my db but the list and the label could be quickly changed so users won't know the difference.
    5. I have one problem with email registration and password reset:
    click here (my domain).com/resetpassword.php?c=(numbers)&email=(myaccountname)%40hotmail.com
    There's a %40 where the @ should be when I look at the emails. I can fix it by hand and then they will work, but my users won't be up for that. Not sure why they are being decoded this way??
    6. I had to change all the 'public_html/index.php' to 'public_index.php' to get all the back links to work.
    7. I get one error on the admin page:
    Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /(lots of stuff)/php/dbcontroller.php on line 433
    Any clue about that?
    8. If you added a simple text form, you'd have a pretty secure user email system going on.

    Thanks. Keep on rockin.

  11. Hi,

    Great script, you really made a lot of changes to the original script.

    I have ran into a problem, I added new fields did the whole process of adding it to the processregister_x and _register functions as well as the dbregister function also added the fields into the database.

    When I test the new fields and click on register the loading image just keeps loading and goes nowhere, but it still sends out the email and creates a new database row.

    Anything I could be doing wrong?

    Thanks.

  12. Hello~

    Could anyone here kindly help to advise who went wrong with script message as follows.

    It’s new installation with db configuration only, wondering if any configuration is missing?!

    Appreciate any advice.

    Warning: mysqli_connect(): (28000/1045): Access denied for user ‘abc’@’111.111.111.111’ (using password: YES) in /abc111/php/dbcontroller.php on line 15 Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /abc111/php/dbcontroller.php on line 455

  13. just found my mistake for the db access configuration. the demo login page is displayed now.

  14. im trying to use another recaptcha for this great script. the registration can now display corresponding message for empty field and wrong recaptcha input respectively, as well as verifying the recaptcha input user keyin is correct.

    However, when the recaptcha input is correct, the previous error message, e.g. empty or wrong input, is still displayed while registration can still be successful.

    Any way to not display the previous error message when the recaptcha input is correct?!

    Any advice is appreciated.

  15. the issue is finally resolved… : )

    it’s related to the html class and id not being specified, so that when mouse cursor was in the input text field, the previous error message was not gone.