1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP Login Script

Discussion in 'Web Development' started by gleno747, Feb 18, 2010.

  1. gleno747

    gleno747 New Member

    I'm not sure if this is the right section.

    Does anyone want to create a login script for my website. I have attached my website files to this thread.

    The "index.html" is the main page for my website. It has a section on there called Members Page. It has a login form. I want this form to find the username & password in a script then if the combination is right it goes to "members-page.html". I don't want a register page link because only i want to be able to add the members to the website. Even if i have to have a register page i want to be the only one to have the link for the page. On the "members-page.html" i want a logout button somewhere.

    If you do decide to do this for me can you PM me with the end result.

    It would be much appreciated by me and my club.

    Thanks
     

    Attached Files:

  2. chanelssc

    chanelssc New Member

    Hi,

    You'll need a bit of php to help you here but it's straightforward.
    The action attribute of your form in your index.html is checklogin.php.
    checklogin.php checks the username and password entered in index.html and compares them against hardcoded values (ideally you would check against a simple database table).
    If the check is successful then the user is brought to members-page.php. This is the same file but with a check to ensure the user is logged in.

    Please see updated zip file attached.

    This is really just to get you started. There are tons of examples online which you should check out.

    I recommend you download and install xampp onto your computer to get started on testing.

    HTH
     

    Attached Files:

  3. gleno747

    gleno747 New Member

    Thanks for that.

    Do you know what the code would be for the code or how to create a simple database table and the links for the other pages.

    Again thanks very much.
     
  4. chanelssc

    chanelssc New Member

    Hi

    MySQL database comes with the xampp install.
    apache friends - xampp for windows

    There is a very easy to use front end called phpMyAdmin which will allow you to create the tables.

    Can you explain to me a bit more what you mean in your first question?

    Installing xampp is your first step then we can get your site running with php.
     
  5. gleno747

    gleno747 New Member

    OK so i got xampp. How do i use it.
     
  6. chanelssc

    chanelssc New Member

    once installed correctly go to http://localhost you should see the xampp homepage
    copy your webpage folder into the htdocs folder (its located in the xampp install folder)
    then you can access your site e.g http://localhost/chrm and it will be able to run php scripts to check login etc
    Use the phpmyadmin http://localhost/phpmyadmin application to create a database
     
  7. gleno747

    gleno747 New Member

    it did not do it i rhink i put the folder in the right place
     
  8. chanelssc

    chanelssc New Member

    hi

    made a small change to the code. see attached.

    not sure what went wrong.
    make sure the apache web server is running (click start from the xampp control panel)
    what happens when you go to http://localhost ?

    the above code is tested and works ok
     

    Attached Files:

    • chrm.zip
      File size:
      291.6 KB
      Views:
      891
  9. gleno747

    gleno747 New Member

    It works now thank you so much. But i have one more question how do i create the log out button on the members page.

    Again THANKS
     
  10. chanelssc

    chanelssc New Member

    You're welcome. You can logout by adding a link to another php script to handle logout and redirect back to the main page. See attached.

    Trying to give you more of an idea how this works than actual implementation.
    Now you have apache \ php \ mysql (i.e xampp) running you should have a look at a different options.

    At the moment I'm setting up a site for my local football team which is why I joined here to get a new logo (thanks again to CovertPea) and I'm using Joomla which has built in support for members login (as well as a ton of other things which you can use or not). I recommend you check it out... they have a demo system you can play with. There are also loads of free templates which you could use then customise for CHRM.

    I realise this might seem like a big jump from a simple php login script but I belive it would be worth the effort.
     

    Attached Files:

    • chrm.zip
      File size:
      291.8 KB
      Views:
      849
  11. gleno747

    gleno747 New Member

    OK thanks I'll give it ago. Also i found that my images weren't showing up but all the links were right.
     
  12. chanelssc

    chanelssc New Member

    Not sure about the images...
    I would say recheck the path to the image but the original zip you attached worked fine for me.
    Do a simpl test and create a new folder in htdocs, then a new php script that points to an image in the same directory i.e <img src="image.jpg"/>
     
  13. gleno747

    gleno747 New Member

    Yea they just suddenly started working. When you get the wrong user name or password it comes up with that all white page and says Wrong User name or Password. Can this be put just below where you login. Like on Myspace. And maybe a "did you forget your password" link.

    Thanks
     
  14. chanelssc

    chanelssc New Member

    As I mentioned its not a full solution hence the white page.
    To achieve what myspace does takes a bit more work (search for ajax login scripts)
    To retrieve a password you could ask the user to enter username and write a script to email the password to the registered email of the user.

    Again Joomla or similar Content Management System will have all this built in.