Re: authorizing through levels! check my code!!

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: authorizing through levels! check my code!!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3007@lists.php.net to get a copy of this message
you are using $myrow again. in first you used it to check login/password. then u use it to get the data. now it has data in it. no login/password. so when you check again for login/password, it shows the message. -- Regards, -- Masood Nasir :-) [Systems Engineer] - http://www.masood.net ;) -- One Net, Lahore, Pakistan. <http://www.one.net.pk> On Sun, 25 Jun 2000, Thomas Edison Jr. wrote: > I have a database with employee information. Each > employee is assigned a level like 1, 2, 3 etc. There > is a page which displays employee information from the > database. There are restrictions for every employee to > view database information according to the level he > possess. For example, an employee with level "1" may > view ALL the records, whereas an employee with level > "2" can view only few records. > > I tried a code to check only for level "1" right now, > and in this case all records should be printed. All > records ARE being printed but so is the line below > "Sorry, you are not authorised to view project > information."!! WHY is this line also being printed?? > What is wrong??? > This line should be printed only when he feeds in a > wrong user & password. > > the code is following with $u & $p being user & > password of the employee entering this page being sent > from the form on the previous HTML file. > > <? > > $db = mysql_connect("localhost", "root"); > mysql_select_db("try",$db); > > $result = mysql_query("SELECT * FROM motorola",$db); > if ($myrow = mysql_fetch_array($result)) { > do { > if ($u == $myrow["user"] && $p == $myrow["pass"]) { > > //authorizing for levels > > if ($myrow["level"] == "1") { > $result = mysql_query("SELECT * FROM motorola",$db); > if ($myrow = mysql_fetch_array($result)) { > do { > printf("name : $myrow[name], email : $myrow[email] > \n"); > > } while ($myrow = mysql_fetch_array($result)); > > } > } > > //ending > break; > } > > } while ($myrow = mysql_fetch_array($result)); > > if ($u != $myrow["user"] && $p != $myrow["pass"]) { > echo "Sorry, you are not authorised to view project > information."; > } > > else { > echo "Sorry, no records matching your criteria were > found in our database."; > } > ?> > > > Please help me someone. > > Regards, > T. Edison jr. > > > > ===== > Rahul S. Johari (Director) > ****************************************** > Abraxas Technologies Inc. > Homepage : http://www.abraxastech.com > Email : abraxastech@yahoo.com > Tel : 91-4546512/4522124 > ******************************************* > > __________________________________________________ > Do You Yahoo!? > Get Yahoo! Mail - Free email you can access from anywhere! > http://mail.yahoo.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#3007) next »