Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Password protecting added profiles via mySQL

    I've made a project where you can add profiles to the site via php forms. I'm storing the info with Sequel Pro. Name and info is all fine but I can't password protect the info so other users can view it without a password.
    Any ideas on how to do so? Thanks.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    simplest way to password protect a page is with http password protection
    PHP Code:
    if(isset($_SERVER['PHP_AUTH_USER']) &&  isset($_SERVER['PHP_AUTH_PW']))
    {
        if((
    "username" == $_SERVER['PHP_AUTH_USER']) &&  ("password" == ($_SERVER['PHP_AUTH_PW'])))
        {
            
    /// Log in successfull :D
            
    main_loop();
        }
        else
        {
            
    //Log in not successfull. Prompt for log in
            
    header('WWW-Authenticate: Basic Realm="Login please"');
            
    header('HTTP/1.0 401 Unauthorized');
        }
    }
    else
    {
        
    //Prompt for log in
        
    header('WWW-Authenticate: Basic Realm="Login please"');
        
    header('HTTP/1.0 401 Unauthorized');


    function 
    main_loop()
    {
       
    //start of main code in here

    If thats what you a trying to do?

    If you want to make you own log in system using html /php would require a bit more work. But could be useful when different users require different passwords.
    Last edited by timgolding; 05-08-2013 at 09:14 AM.
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •