Gossamer Forum
Home : Products : DBMan : Customization :

Small Beginner If/Then Problem

Quote Reply
Small Beginner If/Then Problem
I have been modifying the html.pl to suite my Web site's needs, but have come across a problem. I'm using If statements to make a different message appear based on the permissions for the user. The problem is that when I login (with different user permissions) it always displays every message instead of just the one for those permissions. Here's the code:


<P align="center">
<font face="Arial, Verdana, Helvetica">

|;



print "Welcome! Since you are an administrator, you are allowed to view, add, modify, and delete routes, as well as add, modify, and delete users." if ($per_view || $per_add || $per_del || $per_mod || $per_admin);

print "Welcome! You are allowed to view, add, modify, and delete routes." if ($per_view || $per_add || $per_del || $per_mod);

print "Welcome! You are allowed to view, add, and delete routes, as well as add, modify, and delete users." if ($per_view || $per_add || $per_del);

print "Welcome! You are allowed to view, and add routes." if ($per_view || $per_add);

print "Welcome! You are only allowed to view routes." if ($per_view);



print qq|

If you have any trouble with this system, please email <a href="mailto:WBK73G\@webknights.hypermart.net">Michael DeLong</a>.
</font>
</p>
|; &html_footer; print qq|
</td></tr>
</table>
</body>
</html>
|;
}


Here's what I get:


Welcome! Since you are an administrator, you are allowed to view, add, modify, and delete routes, as well as add, modify, and delete users.Welcome! You are allowed to view, add, modify, and delete routes.Welcome! You are allowed to view, add, and delete routes, as well as add, modify, and delete users.Welcome! You are allowed to view, and add routes.Welcome! You are only allowed to view routes. If you have any trouble with this system, please email Michael DeLong.


Any help is appreciated!

Thanks,


-Michael DeLong
Quote Reply
Re: Small Beginner If/Then Problem In reply to
With the original sub html_home the following displays the permissions users have for your database:

print qq| <$font><b>Permissions:
|;
print " Search " if ($per_view);
print " Add " if ($per_add);
print " Delete " if ($per_del);
print " Modify " if ($per_mod);
print " Admin " if ($per_admin);
print " None " if (!($per_view || $per_add || $per_del || per_mod));
print qq|</b></font>

I think you should be able to modify the print portion to something like the following:

print qq| <$font><b>Welcome! You are allowed to |;
print " Search " if ($per_view);
print " Add " if ($per_add);
print " Delete " if ($per_del);
print " Modify " if ($per_mod);
print " Admin " if ($per_admin);
print " None " if (!($per_view || $per_add || $per_del || per_mod));
print qq| routes.</b></font>

I'm not sure how you would display the various methods are you are trying to do below. Perhaps JPDeni will be back soon with a solution.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Small Beginner If/Then Problem In reply to
In all of your lines, replace || with &&.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Small Beginner If/Then Problem In reply to
JPDeni,

Thanks for the reply. I replaced all the pipes with amperstands but to no joy. They still are being repeated.

Thanks,

Michael

Quote Reply
Re: Small Beginner If/Then Problem In reply to
Let's try it a little differently.

Code:

if ($per_admin) {
print "Welcome! Since you are an administrator, you are allowed to view, add, modify, and
delete routes, as well as add, modify, and delete users.";
}
elsif ($per_mod) {
print "Welcome! You are allowed to view, add, modify, and delete routes.";
}
elsif ($per_del) {
print "Welcome! You are allowed to view, add, and delete routes, as well as add, modify,
and delete users.";
}
elsif ($per_add){
print "Welcome! You are allowed to view, and add routes.";
}
elsif ($per_view) {
print "Welcome! You are only allowed to view routes.";
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Small Beginner If/Then Problem In reply to
And a little difference does the job; it works!!

Thanks JPDeni,

Michael