You are here: Re: two levels of access login script « PHP Programming Language « IT news, forums, messages
Re: two levels of access login script

Posted by jsd219 on 05/31/07 04:19

On May 30, 10:40 pm, jsd219 <i...@musiclanerecording.com> wrote:
> I have a fairly simple login in script and I need to make it have two
> levels of access not one. can anyone help me with this? The script is
> below:
>
> <?php
> // we must never forget to start the session
> session_start();
> $errorMessage = '';
> if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
> include 'config.php';
> include 'opendb.php';
> $userId = $_POST['txtUserId'];
> $password = $_POST['txtPassword'];
> // check if the user id and password combination exist in database
> $sql = "SELECT user_id
> FROM auth_user
> WHERE user_id = '$userId'
> AND user_password = '$password'";
> $result = mysql_query($sql)
> or die('Query failed. ' . mysql_error());
> if (mysql_num_rows($result) == 1) {
> // the user id and password match,
> // set the session
> $_SESSION['db_is_logged_in'] = true;
> // after login we move to the main page
> header('Location: list_pages.php');
> exit;} else {
>
> $errorMessage = 'Sorry, wrong user id / password';}
>
> include 'closedb.php';}
>
> ?>
> <html>
> <head>
> <title>Login</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
> <body>
> <?php
> if ($errorMessage != '') {
> ?>
> <p align="center"><strong><font color="#990000"><?php echo
> $errorMessage; ?></
> font></strong></p>
> <?php}
>
> ?>
> <form method="post" name="frmLogin" id="frmLogin" class="box">
> <table width="400" border="1" align="center" cellpadding="2"
> cellspacing="2">
> <tr>
> <td colspan="2"><b>Login</b></td>
> </tr>
> <tr>
> <td width="150">User Id</td>
> <td><input name="txtUserId" type="text" id="txtUserId" class="box"></
> td>
> </tr>
> <tr>
> <td width="150">Password</td>
> <td><input name="txtPassword" type="password" id="txtPassword"
> class="box"></td>
> </tr>
> <tr>
> <td width="150">&nbsp;</td>
> <td><input type="submit" name="btnLogin" value="Login" class="box"></
> td>
> </tr>
> </table>
> </form>
> </body>
> </html>
>
> thank you in advanced
>
> God bless
> jason

Actually a better way of putting it is, I have two hard coded user ids
and passwords with an aditional field called level. for the sake of
this explanation lets call them.
user_id - abc password - 123 level - 1
user-id - xyz password - 456 level - 2

I have two separate admin pages called list_pages.php and
list_pages1.php

I need a login to allow people that sign in with user_id abc to be
able to access list_pages.php and users that sign in with user_id xyz
to be able to access list_pages1.php

can anyone help, Please. i am quite a novice.

God bless
jason

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация