|
-
February 12th, 2000, 12:38 PM
#1
vbscript?
Hi I wonder if anyone can tell me if this is possible with vbscript, if not what language?
I am creating a website and want a page where a user can select a few options only simply like bgcolor and text colour and edit the text etc.. then I need it to be instantly created online and ready to use. So if the person logged in with the username Martin there new html page would be:
http://www.whateverthehostis/Martin.html
if anyone can give me anyhelp on online tutorials for this sort of thing or anything else it would be great
thanks Martin
-
February 12th, 2000, 04:19 PM
#2
Re: vbscript?
I actually do something very similar to this at http://www.stlvbug.org/choosecode.asp. You can do it with vbscript, but you need ASP on the server's side. I use cookies to hold these values and when they return the text and background and whatever are read from the clients cookies and then the HTML is generated appropriately. If you don't want to use cookies, then you would have to store this information in a database, which is fine because then the user can get the same look and feel from any machine, and it's more "cross-browser" compliant.
More the point of your question though, once they selected the values from your initial form, that information would be sent back up to some ASP page, which would then use the FileSystemObject to generate an .html page with the user's preferences. You could of course name the file whatever you wanted.
Here is some code for suggestive purposes only:
Assumptions:
1) Your are using an NT/IIS webserver.
2) The user's information was just passed to this script on the server.
<%
'Begin MakeUserFile.asp
Dim fso
dim ofiler
dim str
dim sPath
const ForWriting = 2
set fso = server.createobject("Scripting.FileSystemObject")
spath = Server.MapPath("default.asp")
spath = left(spath,(len(spath) - 11)) 'get the physical path to this directoy and chop off the filename.
spath = spath & request.form("UserName") & ".html"
set ofiler = fso.opentextfile(spath,ForWriting,true) 'the path to the file, IOMode, Creatable?)
ofiler.WriteLine "<HTML>"
ofiler.WriteLine "<HEAD><Title>" & request.form("UserName") & "'s Personal Page</Title></HEAD>"
ofiler.writeline "<BODY bgcolor='" & request.form("BackgroundColor") & "' text='" & request.form("TextColor") & "'>
ofiler.writeline "Welcome to your page, " & request.form("UserName")
ofiler.writeline "</BODY>"
ofiler.writeline "</HTML>"
ofiler.close 'saves the file
set ofiler = nothing
set fso = nothing
spath = request.form("UserName") & ".html"
resonse.redirect spath
%>
Agains, this assumes that you have already built the selection form and the submit button posts to MakeUserFile.asp, which happens to reside in the root directory of the web site (along with the default.asp).
Let me know if this doesn't make sense, or if you have any questions.
Hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
February 12th, 2000, 06:20 PM
#3
Re: vbscript?
Hi thanks for the help its just want I want
there is a problem I keep getting this message when I load it:
Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/MakeUserFile.asp, line 27
ofiler.writeline "<BODY bgcolor='" & request.form("BackgroundColor") & "' text='" & request.form("TextColor") & "'>
-------------------------------------------------------------------------------------------------------------------^
can you help?
Get paid to surf I know a way to get you 3 free referrals......I have all the hacks/cheats to make you lots of money...
-
February 12th, 2000, 06:41 PM
#4
Re: vbscript?
Hi, have you checked this code for any errors because I am new to this ASP programming and errors at the bottom line 38 are coming up now too....
thanks MArtin
Get paid to surf I know a way to get you 3 free referrals......I have all the hacks/cheats to make you lots of money...
-
February 14th, 2000, 01:04 PM
#5
Re: vbscript?
I have tested this code and it should do what you are looking for with little modifications:
'here is the form for the user to fill out...
<HTML>
<Body>
<form action=makeuserfile.asp method=post>
Your Name: <input type=text name='UserName'><BR>
Your Preferred Background Color: <select name='BackgroundColor'>
<option selected>White
<option>Blue
<option>Red
<option>Green
<option>Black
<option>Purple
<option>LightGrey
</select>
<BR>
<input type=submit value=' Submit '> <input type=reset value=' Reset '>
</form>
</body></html>
**********************************************************
'here is the code for the makeuserfile.asp
<%@ Language=VBScript %>
<% response.buffer = true %>
<html>
<head>
<title>Untitled</title>
</head>
<%'Begin MakeUserFile.asp
Dim fso
dim ofiler
dim str
dim sPath
const ForWriting = 2
set fso = server.createobject("Scripting.FileSystemObject")
spath = Server.MapPath("default.asp")
spath = left(spath,(len(spath) - 11)) 'get the physical path to this directoy and chop off the filename.
spath = spath & request.form("UserName") & ".html"
set ofiler = fso.opentextfile(spath,ForWriting,true) 'the path to the file, IOMode, Creatable?)
ofiler.WriteLine "<HTML>"
ofiler.WriteLine "<HEAD><Title>" & request.form("UserName") & "'s Personal Page</Title></HEAD>"
ofiler.writeline "<BODY bgcolor='" & request.form("BackgroundColor") & "' text='" & request.form("TextColor") & "'>"
ofiler.writeline "Welcome to your page, " & request.form("UserName")
ofiler.writeline "</BODY>"
ofiler.writeline "</HTML>"
ofiler.close 'saves the file
set ofiler = nothing
set fso = nothing
spath = request.form("UserName") & ".html"
response.redirect spath
%>
<body>
</body>
</html>
You will have to add items to the form for the things you want, like text color etc.
good luck,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|