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: Prepare for advanced communication roles and earn your Northwestern master’s degree online.


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.

CSS Reference

Learn about all important CSS properties from the basics with our extensive and easy-to-read CSS Reference.

It doesn't matter if you are a beginner or intermediate, start learning CSS now.

Feedback 287

Comments are closed.
    • ok, let’s check the following things:

      1. You didnt change the folder structure. The style.css is in the folder css.
      2. The public_index.php is in the root folder and has this line in the head:

      3. You didn’t change the class of the form (class=”login”)
      4. You cleaned your cache.

      Does any change to the style.css has effects?

      greetings

  1. Hi

    I fixed it. Dreamweaver was not uploading properly to the testing server.

    Thanks so much.

    Cheers
    p.s cant

  2. Chad,

    I had the same problem John did where the captcha image wasn’t showing up. I also renamed it to image.php and it worked fine.

    I’d rather fix the real problem that use the workaround. Do know what the real issue is? I noticed that when I point my browser to image.jpg I get this error: “Permission denied (13) in ../images/captcha/image.jpg on line 3. Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent”

    Thanks for the great code and expert support!

    Matt

  3. Hey Chad,
    Thanks for this updated script. Really appreciate it. I have one *small* request though.

    Would you be able to provide a few more lines of code I can add so I can register session variables (like putting the user’s full name in a session variable) so I can call on it once they log in?

    Thanks a lot!

  4. Hey Chad,

    I have a question:
    I would like to change email adress to the name when i login? How can I do that?

    Here is the code:
    echo “Welcome “.$objCore->getSessionInfo()->getUserInfo(’email’).”, you are logged in. ”

    Thanks,
    Buco

    • Hi,
      you need to call

      $objCore->getSessionInfo()->getUserInfo(‘flname’)

      instead! But for that you need to change the line 230 of the file dbcontroller.php (function dbgetUserInfo) to this:

      $q = “SELECT pk_user,email,usr_userid,flname FROM users WHERE pk_user = ‘$username'”;

      I think this answers as well your question Chris?

      greetings

  5. About the captcha image, I’m not sure what can be the problem! Maybe the permissions for the folder where that file is?? Anyway thats a php file so it should be actually renamed to image.php.
    greetings

  6. Hey Chad,

    thank you for the guick answer, it is working!

    I have an other question:
    Do you think about the loginsystem make to multilanguage system?

    For example, I can change the language from english to anything else?

    Thanks,
    Buco

  7. So towards the top of the file, i put this out:

    $objCore->getSessionInfo()->getUserInfo(‘flname’);
    $flname = $_SESSION[‘flname’];

    and i tried echoing out $flname.. but nothing shows up.. i would debug this further.. but i don’t think i really get the concept of the objcore->getsessioninfo->getuserinfo code.. im used to coding in the old php format…

    if you could explain briefly what the code is doing.. and how i would extract info from the code… it would be hugelyyyy helpful as i could then debug/figure out future problems on my own (through trial and error)…

    but if you don’t have the time.. could you simply fix the code so i would be able to output/echo flname?

    thanks a lot chad

    • Hi,
      you need to insert this line:
      “Welcome “.$objCore->getSessionInfo()->getUserInfo(’flname’).”
      instead of
      “Welcome “.$objCore->getSessionInfo()->getUserInfo(’email’).”

      But before you should get that value from the table:

      line 230 of the file dbcontroller.php (function dbgetUserInfo):

      $q = “SELECT pk_user,email,usr_userid,flname FROM users WHERE pk_user = ‘$username'”;

      that value is not stored in SESSION variables, but in the php sessioninfo object!

      greetings

  8. Hey Chad,

    I am still having a problem with the CAPTCHA. I changed the image.jpg to image.php but still get that same error.

    Other than the file change, do I need to change anything else?

    Thanks,

    James

    • James,
      What exactly is the error message that you see?
      Anyway, I will soon post some update where I replaced that image captcha script for a better one. There will be no image.jpg/php file anymore.
      greetings

  9. My frustration in integrating this into my website is that the css that comes with this conflicts with my existing css. Is there a good way to handle this problem?

    thanks!

    • Hi,
      well, the only advice I could give you is that you either use the included css as a starting point or you remove it completly and do one by yourself.
      If you had already some project where you integrated this login script, then it would be better to remove the css I provided. Just start taking out piece by piece from it and see where the conflits is :S
      greetings

  10. Chad,
    Thanks for the reply. I’ll just wait for the new script. No sense of trying to fix something that is gonna change.

    Cheers,

    James

  11. will it be hard to just replace the new captcha with the one currently up?

    anyways.. dont’ reallly have a question. just wanted to say thanks for everything you’re doing for all of us. im sure it a pretty thankless job…

    so a big thanks!

  12. anyone with any coding experience help me please?

    I made a website for my F1 simracing a while back, anyway the linking i used is no longer working.

    i use this link:

    echo “”. $shownews .”…….Read More“;

    the url address has the id in it ie: news.php?id=13

    and the news page has the following in it:

    $kysely = mysql_query(“select * FROM igpcnews WHERE id=’$nid'”,$yhteys);

    but i always get

    Notice: Undefined variable: nid in C:\wamp\www\site\news.php on line 41

    This used to work a few years ago, im guessing the newer PHP dont work the same as the older because i dont know whats up with it.

    Can anyone help??

    Im sorry that this is not the right place to post this but i didnt know where else to post it

  13. the url address has the id in it ie: news.php?nid=13

    TYPO the url address is correct, it wont pick up the variable though 🙁

  14. really sorry about this, if anyone has any link to somewhere where these questions are more appropriate please pass it on 🙂

    Been years since i did any of this and i am trying to teach it all to myself again

  15. try :

    $val=$_GET[‘nid’];
    mysql_query(“select * FROM igpcnews WHERE id=’$val'”,$yhteys);