English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Looks good. You don't really need
if (authenticated_user()) {
$authorized = true;
}
That block. If, what I think, authenticated_user() is a function that returns true or false if the user is authenticated or not, you can just set $authorized=authenticated_user...
then if($authorized==true)

2006-06-19 07:08:24 · 4 answers · asked by dude 3 in Computers & Internet Programming & Design

4 answers

Yes -- if the function authenticated_user() returns a boolean then just use $authorized = authenticated_user() and you should be fine. So whatever the function returns will be stored in the authorized variable. Then you can check if it is either tru or false and do whatever you want with it.

2006-06-19 07:12:57 · answer #1 · answered by Mr. Me 3 · 0 0

I would code it like so (in PHP):

$authorized = authenticated_user();
if ($authorized) {
// ...do something for real users...
} else {
// ...do corresponding thing for anonymous users...
}

By using if($authorized) instead of if($authorized==true) you make more concise and readable code. If $authorized might have a number of values that equal True, and you need to distinguish the actual boolean True, then use if($authorized===true) [note three equals signs] instead..... but that's very poor coding style, it can be confusing and it's subject to typographical errors causing bugs.

2006-06-19 14:32:21 · answer #2 · answered by poorcocoboiboi 6 · 0 0

Seems ok, but I prefer Visual Basic code as it's more user friendly!

eg:
dim pw as integer
if input.pw<>******** then
msgbox "Invalid Password - you have been locked out of this PC!"
end
end sub

2006-06-19 14:13:59 · answer #3 · answered by Kewl Dude Ganda 3 · 0 0

I agree with Mr. Me. you don't need the if, it's redundant. just do

$authorized = authenticated_user()

2006-06-19 14:19:27 · answer #4 · answered by Deep Thought 5 · 0 0

fedest.com, questions and answers