Help with a script please

This is a discussion on "Help with a script please" within the Classic ASP section. This forum, and the thread "Help with a script please are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Apr 9th, 2004, 07:24
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Help with a script please

Ok, I've been playing around with asp trying to create a user management site, just mucking around. I've been able to create the login and sign up pages, and everything works fine. Now I'm trying to create an admin section. I've included a field in the database to show whether a user is an admin or not and I have created the following code. Members must be logged in to view the page, and admins are redirected to another page of their own, admin.asp

Code: Select all
<%
Dim ConnectString, conn, rsAdmin

if Session("username") = "" then
  Response.Redirect("nologin.asp?page=membersonly.asp")
end if

ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/siteusers.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString

sql = "SELECT admin FROM Users WHERE username = '" & username & "'"
Set rsAdmin = Server.CreateObject("ADODB.Recordset")
rsAdmin.Open sql, conn, 3, 3 

if rsAdmin("admin")=1 then
 Reponse.Redirect("admin.asp")
else

%>
<html>
<head>
<title>Members only page</title>
</head>
<body bgcolor="#FFFFFF" link="#DD0000" vlink="#DD0000" alink="#000000">
<font face="arial,helvetica" size=2>

<h2>Members only page</h2>


Back to the home page</p>

</font>
</body>
</html> 

<%
end if

rsAdmin.close
set rsAdmin = nothing
conn.close
set conn = nothing

%>
But, I'm getting the error:

Error Type:
(0x80020009)
Exception occurred.
/membersonly.asp, line 16

but what is wrong with line 16?? What is the exception?

any help would be greatly appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Apr 9th, 2004, 09:45
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Try using this:-
Code: Select all
if cInt(rsAdmin("admin")) = 1 then
If this works, then it is because you are comparing an integer to a variant / string.

If this does not work, then post back along with a schema for the table including field types.

Cheers
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Apr 9th, 2004, 09:47
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Actually.... it may be because you don't have a record...

Try this too:-
Code: Select all
sql = "SELECT admin FROM Users WHERE username = '" & session("username") & "'"
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Apr 10th, 2004, 01:08
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
of course...

I've just added at the top of the script:
Code: Select all
username = Session("username")
but now I get this error:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'Reponse'
/secure/membersonly.asp, line 19

line 19 is
Response.Redirect("admin.asp")

I don't understand it. Sorry if these are really obvious mistakes, I'm learning...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old Apr 10th, 2004, 02:51
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
'Reponse'

from that I'd say you have Reponse.Redirect on line 19 instead of Response.Redirect
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old Apr 10th, 2004, 07:31
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
yes.... lol I do that all the time.... easy done.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #7  
Old Apr 10th, 2004, 08:23
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
doh!

How stupid of me...I feel really embarrassed now.

Thanks guys! I'll read my script more carefully next time!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #8  
Old Apr 10th, 2004, 08:26
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
That fixed it. Now I can get on with the admin's page. Thanks guys!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #9  
Old Apr 10th, 2004, 08:59
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
don't feel stupid Tim356 ... im still having problems with my log-in script, hahaha... I can get it to connect but not to check the passwords. Well, I will keep at it till I get it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #10  
Old Apr 10th, 2004, 10:14
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Well, keep at it.

Now I'm having problems with adding stuff to my database... I'm just testing it by creating a simple forum type thing, but only for members, where they enter comments and then it displays all comments posted. I'm trying to set it up so that it automatically adds to the database which user is posting, but do you think I can?? It's ****ting me, cause I know it's simple, but I'm doing heaps of things wrong...

very frustrating, but I'll keep going...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #11  
Old Apr 10th, 2004, 13:42
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
well.... post back if you get stuck!
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #12  
Old Apr 10th, 2004, 14:57
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Rob, your help (everyone's help for that matter) is appreciated!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #13  
Old Apr 11th, 2004, 06:15
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
I guess I'd say try a cookie. You could always look at any of the free tag-board scripts out there and see how they do it to get ideas too.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #14  
Old Apr 11th, 2004, 07:08
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
only problem with cookies is that most people's browsers do not accept them. Actually, JavaScript AND VBScript can be disabled too.. Thats so sad.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #15  
Old Apr 11th, 2004, 08:45
Tim356's Avatar
Reputable Member
Join Date: Nov 2003
Location: Australia
Age: 26
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
I'm still working out cookies...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #16  
Old Apr 11th, 2004, 18:00
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,186
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">only problem with cookies is that most people's browsers do not accept them<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote"> Most browsers? Really Court Jester... you ought to check you facts. Nearly all browsers accept them, and nearly everyone has them enabled.

I've told you a thousand times not to exaggerate.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #17  
Old Apr 11th, 2004, 20:02
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Really now? Hrmm.. Not what I have been reading up lately. Actually Most browsers don't accept them.. The default setting in Internet Explorer is to not accept cookies from most websites... and I know like 50% of the people using the net don't even know how to change thier settings... So At least 50% of them won't accept cookies... probably more, which makes it most people :wink:.

Now if you accept the websites privicy policy, or you accept their security settings, then yes you will be able to use cookies on that website witht the default settings of Internet explorer...
Code: Select all
Cookies or cookieless ? 
I just have a look at some stats on one of my project and I discovered that more than 53 % of the users of this website are still blocking cookies.

February 10th 2004
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #18  
Old Apr 11th, 2004, 21:15
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Did you know that 84% of statistics are made-up?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #19  
Old Apr 12th, 2004, 04:05
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Sure they are D3mon.. I don't know about you, I am sure you make up yours, but mine aren't made up... they are cold hard facts.. Did you know that when people try to talk against statistics without any content they look unintellegint?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #20  
Old Apr 12th, 2004, 05:18
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
:wink: Why is it when people spell 'unintellegint' they come of looking unintelligent? :wink:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
help, script

«