473,322 Members | 1,232 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

login script with two levels of access

Can anyone help with this code please! I am a novice and need help.

I have two hard coded user ids and passwords with an additional 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 login "abc" to be
able to access "list_pages.php" and people that login in with "xyz"
to be able to access "list_pages1.php"

can anyone help, Please. I am desperate

God bless
jason

May 31 '07 #1
4 3687
Well...

Try this...

It's a little rough but you should get the basic idea.
-------------
<?php
$user1 = "abc";
$user2 = "xyz";
$pass1 = "123";
$pass2 = "456";

$action = (isset($_POST["submit"])) ? $_POST["submit"] :NULL;

if($action == "submit") {
$showForm = false;
$user = $_POST["username"];
$pass = $_POST["password"];
if($user == $user1 && $pass == $pass1) {
/* Include your files here for user1. */
}elseif($user == $user2 && $pass == $pass2) {
/* Include your files here for user2. */
}else{
/* Do error stuff here. */
$showForm = true;
}
}
?>
<?php if($showForm == true) {
<form method="post" action="index.php">
<label for="username">Username:</label>
<input id="username" name="username" type="text" value="" />
<label for="password">Password:</label>
<input id="password" name="password" type="password" value="" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php } ?>

May 31 '07 #2
On May 31, 9:31 am, SterLo <sterling.hamil...@gmail.comwrote:
Well...

Try this...

It's a little rough but you should get the basic idea.
-------------
<?php
$user1 = "abc";
$user2 = "xyz";
$pass1 = "123";
$pass2 = "456";

$action = (isset($_POST["submit"])) ? $_POST["submit"] :NULL;

if($action == "submit") {
$showForm = false;
$user = $_POST["username"];
$pass = $_POST["password"];
if($user == $user1 && $pass == $pass1) {
/* Include your files here for user1. */
}elseif($user == $user2 && $pass == $pass2) {
/* Include your files here for user2. */
}else{
/* Do error stuff here. */
$showForm = true;
}
}
?>
<?php if($showForm == true) {
<form method="post" action="index.php">
<label for="username">Username:</label>
<input id="username" name="username" type="text" value="" />
<label for="password">Password:</label>
<input id="password" name="password" type="password" value="" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php } ?>
Will this not show the user names and passwords in the source code
allowing anyone to pull up the code and get the passwords?

God bless
jason

May 31 '07 #3
jsd219 wrote:
On May 31, 9:31 am, SterLo <sterling.hamil...@gmail.comwrote:
>Well...

Try this...

It's a little rough but you should get the basic idea.
-------------
<?php
$user1 = "abc";
$user2 = "xyz";
$pass1 = "123";
$pass2 = "456";

$action = (isset($_POST["submit"])) ? $_POST["submit"] :NULL;

if($action == "submit") {
$showForm = false;
$user = $_POST["username"];
$pass = $_POST["password"];
if($user == $user1 && $pass == $pass1) {
/* Include your files here for user1. */
}elseif($user == $user2 && $pass == $pass2) {
/* Include your files here for user2. */
}else{
/* Do error stuff here. */
$showForm = true;
}
}
?>
<?php if($showForm == true) {
<form method="post" action="index.php">
<label for="username">Username:</label>
<input id="username" name="username" type="text" value="" />
<label for="password">Password:</label>
<input id="password" name="password" type="password" value="" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php } ?>

Will this not show the user names and passwords in the source code
allowing anyone to pull up the code and get the passwords?

God bless
jason
Jason,

It could - if they could display the code. A properly configured
webserver will parse the code and only send the results to the browser,
not the code.

But your concern is well founded. I normally put user id's and
passwords in an include file outside the document root.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 31 '07 #4
C.
On 31 May, 19:58, Jerry Stuckle <jstuck...@attglobal.netwrote:
>
It could - if they could display the code. A properly configured
webserver will parse the code and only send the results to the browser,
not the code.

But your concern is well founded. I normally put user id's and
passwords in an include file outside the document root.
See also the recent thread 'how to not write password in code for
using to mysql?'

(also at http://groups.google.co.uk/group/com...df0802/?hl=en#)

C.

May 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: koolyio | last post by:
Hey, could you please tell me what is wrong with my login script. I just started learning php. CODE: login.php <? session_start(); header("Cache-Control: private"); ?>
1
by: Homa | last post by:
Hi, I am using a role-based Forms Authentication. I have several directories that have different levels of authorization. When I try to access another directory, the page bounce me back to the...
2
by: Assimalyst | last post by:
Hi, I am creating a website where i want to allow some webforms to be accessible to all users, and those in a subdirectory available only to authenticated users. I have created a script to...
14
by: knal | last post by:
Hi there, I'm looking for a secure login script for a sort-of-community site... (PHP, MySQL, sessions, or maybe something else ... ) I know there are a lot of scripts out there, but none of them...
1
by: jsd219 | last post by:
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...
3
by: Jennifer.Berube | last post by:
okay...so I got this login script and I edited it all and it seems to run fine...IE it listens to the script as far as permissions go when I place a restriction on a page and when you login it...
5
by: muppetjones | last post by:
I'm really new to the whole networking side of things, so I don't know the backend very well. I wrote a series of PHP/AJAX scripts to allow a user to create a login account, but apparently my script...
5
by: Mai Le | last post by:
Hello Experts. Coul you please help me to fix my program. I created a login from with 2 levels. Admin an User. If Admin login will open A form and If User login will open B form I had table...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.