Page 1 of 1

PHP Login as user not admin

Posted: Fri May 07, 2010 11:35 pm
by Hackit
Hi everyone, first let me say I'm so new to php. sucks being the low guy on the totem pole...

If some one could please let me know what i'm doing wrong or missed i would be very happy and grateful.

Ok I have a php login that allows me to login as the admin, I can then use the admin features of mysql database and edit what I need through my browser.

Now I would like to add a user login so they can view the web pages but not edit them.

this is what the settings.php look like:
------------------------------------------------------------------------------------

Code: Select all

<?php

// The settings file, where you specify the various options for the system

/* administration settings */
/* you should always supply a password, even if you do not require logins (it is used to prevent XSRF attacks) */
$requirelogin = true; //use false if you do not want to have to log in to use the system
$adminname = 'me';---works and I can login in and edit the info.
$adminpass = 'pass';
$adminname = 'user';---works but can still edit the info, I also tried to create a new mysql user with limited rights but it did not work.
$adminpass = 'pass';
$authrealm = 'Movie database'; //just a name - make sure /images/*/.htaccess uses the same realm
$usecookies = false; //set to true to use cookies for logging in - some servers cannot use normal HTTP authentication and need cookies

/* database settings - these are the values you used when setting up the MySQL server */
$host = 'localhost';
$username = 'user-name';
$password = 'pass';
$database = 'mysql database';

/* other settings */
  /* the MIME type tells the browser if the page is HTML or XHTML  - the pages all use XHTML markup, but IE needs you
     to pretend you are using plain HTML;
     * use 'text/html;charset=utf-8' if you need it to work in IE (or Safari, due to rendering bugs)
     * use 'application/xhtml+xml;charset=utf-8' if you are only using a good browser - note that any HTML you put in
       any database fields must be valid XHTML fragments */
$defaultmime = 'text/html;charset=utf-8';
  /* should the navigation appear before the main content in the document source
     this does not affect the layout with the defaul stylesheet, but it will change it for browsers that do not use the
     stylesheet, and you may need to change it for custom stylesheets */
$navfirst = false; //use true to put the navigation blocks before the main content
  /* should category management be done on a separate page, or as part of the movies listing page
     (makes the movies page cluttered) */
$separatecategory = true; //use false to put them as part of the movies page
  /* movie counting (shown beside categories) can be:
     * 'simple' = [total for this and sub-categories]
     * 'normal' = [total for this category, total for sub-categories]
     * 'detailed' = [total for this category, total for sub-categories (count sub-categories)] */
$movcount = 'normal';
  /* on movie details pages, actor ages can be displayed as the calculated age when the movie was
     made, or their current age */
$showcurrentage = false; //use true to show current age
  /* should the browser be allowed to cache pages
     preventing caching may cause form changes to be lost when going back to them - will be annoying
     Note: Opera will always cache some pages (such as movie or actor details) unless you use HTTPS */
$allowcaching = true; //use false to prevent caching
  /* does your MySQL install support utf-8?
     name sort orders may be wrong if you use non-latin characters in a latin database, so utf-8 is better, if
     it is available
     IMPORTANT: never change this setting after you have created the database tables
     table contents of utf-8 and latin are incompatible with each other (if they contain any non-latin characters)
     never recover the contents of a database if they were dumped from the other type */
$supportsutf8 = true; //use false to use latin encoding
-------------------------------------------------------------------------------------------------------------------------------------------

I was thinking I might need to create a new index.php page for just users, is this thinking right?
This would require alot more work, so I'm hoping i can just add a user login and not let them click the admin link and add content.

If this does not make sense sorry, if you need more info I will do my best.

Thanks

Re: PHP Login as user not admin

Posted: Sat May 08, 2010 4:53 am
by social_experiment
Add a 'user_level' field in the database and when the user (admin or otherwise) has logged in let this value determine what set of links (if any) will be displayed. In that way you have your current amount of pages working for both admin and non-admin users.