New to ASP need help

Discussion in 'ASP General' started by Thomas R Grassi Jr, Feb 8, 2009.

  1. <%
    Set fs = CreateObject("Scripting.FileSystemObject")

    Folderpath=server.mappath("\") & "/cgi-bin/guestbook"
    Wcounter=Folderpath &"/counter.txt"

    I am trying to add a guestbook to my web site and I found asp code very
    simple guestbook nothing fancy here

    I question I have is stupid but I am not sure what the asp programmer is
    looking for here.

    the line Folderpath=server.mappath("\") & "/cgi-bin/guestbook"

    server.mappath what should I put there?

    in windows explorer I have c:\inetpub\wwwroot\cgi-bin

    My server name is pcserv01

    in IE7 I can get to the default web site via www.tomtest.com

    on the default.htm page I have a hyperlink to guestbook.htm which is the
    form for this asp code.

    So I am not sure what to place in server.mappath

    here is the entire asp code
    <%
    Set fs = CreateObject("Scripting.FileSystemObject")

    Folderpath=server.mappath("\") & "/cgi-bin/guestbook"
    Wcounter=Folderpath &"/counter.txt"

    if request.form<>"" then

    Wemail = Request.Form("visitorsemail")
    test1=instr(Wemail, "@") ' value must be >1
    test2=instr(Wemail, ".") ' value must be >4
    test3=len(Wemail) ' value must be >6
    test4=InStr (test1,Wemail,".",1) ' value must be >test1+2

    if test1<2 OR test2<5 OR test3<7 OR test4<test1+3 then
    response.write(Wemail & " is not a valid email address<p>")
    email_Test=0
    else
    email_Test=1
    end if

    if email_Test=1 then
    Set fs = CreateObject("Scripting.FileSystemObject")
    if fs.FolderExists(Folderpath) then
    Set a = fs.OpenTextFile(Wcounter)
    counter = Clng(a.ReadLine)
    counter = counter + 1
    a.close
    else
    Set a = fs.CreateFolder(Folderpath)
    counter=1
    end if

    Set a = fs.CreateTextFile(Wcounter,True)
    a.WriteLine(counter)
    a.Close
    Set fs=nothing

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile(Folderpath & "\" & counter & ".txt")
    a.WriteLine("<b><a HREF=mailto:" & Request.Form("visitorsemail") &
    ">" &

    Request.Form("visitorsname") & "</a></b>")
    a.WriteLine(Request.Form("visitorsmessage"))
    a.Close
    Set a=nothing
    Set fs=nothing
    end if
    end if


    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(Folderpath)
    Set fc = f.Files

    Response.Write ("<HTML><HEAD><TITLE>Guest book</TITLE></HEAD>")
    Response.Write ("<BODY BGCOLOR=FFFFFF>")
    Response.Write ("<TABLE BORDER=0 Width=100" & CHR(37) & ">")
    Response.Write ("<TR><TD BGCOLOR=C0C0C0>")
    Response.Write ("<FONT SIZE=5><B>Guest book: posted messages</B></FONT>")
    Response.Write ("</TD></TR></TABLE>")

    For Each f1 in fc
    Wfile=f1.name
    if Wfile<>"counter.txt" then
    FiletoCheck=Folderpath & "/" & Wfile
    Set a=fs.OpenTextFile(FiletoCheck)

    Theinfo="<pre>" &a.ReadAll & "</pre><hr>" & Theinfo

    end if
    Next
    Response.write(Theinfo)
    Response.write("<div align=right><font size=2>Script provided by <a

    href=http://www.asptutorial.info>asptutorial.info</a></font></div>")

    Response.Write ("</BODY></HTML>")

    %>


    Any ideas or suggestions

    Thanks

    Tom
    Thomas R Grassi Jr, Feb 8, 2009
    #1
    1. Advertising

  2. I got it working had a syntex error on another line m foderpath line was ok


    Thanks

    Tom
    "Thomas R Grassi Jr" <> wrote in message
    news:...
    > <%
    > Set fs = CreateObject("Scripting.FileSystemObject")
    >
    > Folderpath=server.mappath("\") & "/cgi-bin/guestbook"
    > Wcounter=Folderpath &"/counter.txt"
    >
    > I am trying to add a guestbook to my web site and I found asp code very
    > simple guestbook nothing fancy here
    >
    > I question I have is stupid but I am not sure what the asp programmer is
    > looking for here.
    >
    > the line Folderpath=server.mappath("\") & "/cgi-bin/guestbook"
    >
    > server.mappath what should I put there?
    >
    > in windows explorer I have c:\inetpub\wwwroot\cgi-bin
    >
    > My server name is pcserv01
    >
    > in IE7 I can get to the default web site via www.tomtest.com
    >
    > on the default.htm page I have a hyperlink to guestbook.htm which is the
    > form for this asp code.
    >
    > So I am not sure what to place in server.mappath
    >
    > here is the entire asp code
    > <%
    > Set fs = CreateObject("Scripting.FileSystemObject")
    >
    > Folderpath=server.mappath("\") & "/cgi-bin/guestbook"
    > Wcounter=Folderpath &"/counter.txt"
    >
    > if request.form<>"" then
    >
    > Wemail = Request.Form("visitorsemail")
    > test1=instr(Wemail, "@") ' value must be >1
    > test2=instr(Wemail, ".") ' value must be >4
    > test3=len(Wemail) ' value must be >6
    > test4=InStr (test1,Wemail,".",1) ' value must be >test1+2
    >
    > if test1<2 OR test2<5 OR test3<7 OR test4<test1+3 then
    > response.write(Wemail & " is not a valid email address<p>")
    > email_Test=0
    > else
    > email_Test=1
    > end if
    >
    > if email_Test=1 then
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > if fs.FolderExists(Folderpath) then
    > Set a = fs.OpenTextFile(Wcounter)
    > counter = Clng(a.ReadLine)
    > counter = counter + 1
    > a.close
    > else
    > Set a = fs.CreateFolder(Folderpath)
    > counter=1
    > end if
    >
    > Set a = fs.CreateTextFile(Wcounter,True)
    > a.WriteLine(counter)
    > a.Close
    > Set fs=nothing
    >
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > Set a = fs.CreateTextFile(Folderpath & "\" & counter & ".txt")
    > a.WriteLine("<b><a HREF=mailto:" & Request.Form("visitorsemail") &
    > ">" &
    >
    > Request.Form("visitorsname") & "</a></b>")
    > a.WriteLine(Request.Form("visitorsmessage"))
    > a.Close
    > Set a=nothing
    > Set fs=nothing
    > end if
    > end if
    >
    >
    > Dim fs, f, f1, fc, s
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > Set f = fs.GetFolder(Folderpath)
    > Set fc = f.Files
    >
    > Response.Write ("<HTML><HEAD><TITLE>Guest book</TITLE></HEAD>")
    > Response.Write ("<BODY BGCOLOR=FFFFFF>")
    > Response.Write ("<TABLE BORDER=0 Width=100" & CHR(37) & ">")
    > Response.Write ("<TR><TD BGCOLOR=C0C0C0>")
    > Response.Write ("<FONT SIZE=5><B>Guest book: posted messages</B></FONT>")
    > Response.Write ("</TD></TR></TABLE>")
    >
    > For Each f1 in fc
    > Wfile=f1.name
    > if Wfile<>"counter.txt" then
    > FiletoCheck=Folderpath & "/" & Wfile
    > Set a=fs.OpenTextFile(FiletoCheck)
    >
    > Theinfo="<pre>" &a.ReadAll & "</pre><hr>" & Theinfo
    >
    > end if
    > Next
    > Response.write(Theinfo)
    > Response.write("<div align=right><font size=2>Script provided by <a
    >
    > href=http://www.asptutorial.info>asptutorial.info</a></font></div>")
    >
    > Response.Write ("</BODY></HTML>")
    >
    > %>
    >
    >
    > Any ideas or suggestions
    >
    > Thanks
    >
    > Tom
    >
    >
    >
    Thomas R Grassi Jr, Feb 9, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. soni29
    Replies:
    0
    Views:
    337
    soni29
    Nov 30, 2003
  2. Replies:
    0
    Views:
    347
  3. Dean Craig
    Replies:
    3
    Views:
    494
    Dean Craig
    Nov 13, 2006
  4. ali
    Replies:
    2
    Views:
    106
    Jeff Cochran
    Apr 23, 2004
  5. Replies:
    2
    Views:
    437
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page