hi guys! Can anyone help me in this code...
I just copied it in a book but i cannot find what's wrong.My teacher don't want to tell what's wrong but she said that i have to change something in the code but i can't find it. So please help me...Here's the code....
default.htm
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM id="frmSearch" name="frmSearch" action="form.asp" method="get">
<CENTER><H1>Students Contact Information</H1>
<CENTER><H2>Main Menu</H2></CENTER>
<CENTER>
<A href="form.asp?Mode=New&txtLastName=&FirstName=&"> Create a new student</A></CENTER>
<CENTER><H2>Search Form</H2></CENTER>
<CENTER>
<P>
<INPUT type="hidden" name="Mode" value="Browse">
First name: <INPUT type="text" name="txtFirstName" size="30">
<BR>
Last name: <INPUT type="text" name="txtLastName" size="30">
</P>
</CENTER>
<CENTER>
<P><INPUT id="cmdSubmit" type="submit" value="Search">
<INPUT id="cmdReset" type="reset" value="Cancel"></P>
</CENTER>
</FORM>
</BODY>
</HTML>
form.asp
<% @ Language=VBScript %>
<% Option Explicit%>
<% Response.buffer=true%>
<!--#include file="clsForm.cls"-->
<html>
<head>
<title>Student Contact</title>
<%
Dim objForm,objFileSystemObject
set objForm=new clsForm
set objFileSystemObject=CreateObject("Scripting.FileSy stemObject")
objForm.ServerPath=Server.Mappath("/Register")&"\students.txt"
If objFileSystemObject.FileExists(ObjForm.ServerPath) Then
objForm.Mode=Request.QueryString("Mode")
If Request.QueryString("Mode") = "Browse" then
QueryString("txtLastName")<>"" Then
If Not objForm.Search(Request.QueryString("txtFirstName") ,Request.QueryString("txtLastName")) then
Response.Redirect("form.asp?Mode=New&txtFirstName= &txtLastName=")
End If
End If
End If
'Else
objForm.colForm.Mode="New"
objForm.colFormElements.RemoveAll
objForm.colFormElements.Add "txtFirstName", ""
objForm.colFormElements.Add "txtLastName", ""
objForm.colFormElements.Add "txtWorkPhone", ""
objForm.colFormElements.Add "txtHomePhone", ""
objForm.colFormElements.Add "txtemail", ""
End If
set objFileSystemObject=Nothing
%>
</head>
<body>
<h1 align="center">Student contact</h1>
<p align="center"><strong>Instructions:</strong>
You nedd to fill in this information</p>
<form id="frmRegister" name="frmRegister" action="register_me.asp" method="post">
<center><p><b>Personal Information</b></p></center>
<center><p>First name: <input id="txtFirstName" name=txtFirstName" size="35" value="<%=objForm.colFormElements.Item("txtFirstNa me")%>">*<br>
Last name:
<input id="txtLastName" name="txtLastName" size="35" value="<%=objForm.comFormElements.Item("txtLastNam e"%>"><strong>*</storng></label></p>
</center>
<center<p><b>Contact Information</b></p>
</center>
<center><p>Home phone:<input type="text" name=txtHomePhone" size="12" value="<%=objForm.colFormElements.Item("txtHomePho ne")%>">*<br>
Work phone:<input type="text" name="txrtWorkPhone" size="12" value="<%=objForm.colFormElements.Item("txtWorkPho ne")%>">*<br>
E-mail:<input type="text" name="txrtemail" size="12" value="<%=objForm.colFormElements.Item("txtemail") %>"><strong>*</stonrg></p>
</center>
<%If (objForm.Mode <> "Browse") Then %>
<center><p><input id="cmdSubmit" type="submit" value="Save">
</p></ceter>
<%Else%>
<center>Back to a<a href="default.htm">Search</a>.</center>
<% End If %>
</form>
</body>
</html>
clsform.cls:
<%
CLASS clsForm
Private strMode
Public colFormELements
Private strServerFilePath
Public Sub Class_Initialize
strmod = "Browse"
set colFormElements = CreateObject("Scripting.Dictionary")
strServerFilePath = Server.MapPath("/Chapter_4/register")
"\students.txt"
Call CreateDict
End Sub
Public Function Search(strFirstName,strLastName)
Dim objFile,objFileSystemObject,ObjFS,strDummy1,strDum my2,strDummy3,strFirst,strLast
set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
set objFile = objFileSystemObject.GetFile(strServerFilePath)
set objFS = objFile.AtEndofStream
strFirst = UCASE(objFS.ReadLine)
strLast = UCASE(objFS.ReadLine)
if(UCASE(strFirstName) = strFirst) and (UCASE(strLastName = strLast) Then
strMode = "Browse"
colFormElemetns.RemoveAll
colFormElements.Add "txtFirstName", strFirstName
colFormElements.Add "txtLastName", strLastName
colFOrmElements.Add "txtWorkPhone", objFS.ReadLine
colFormElements.Add "txtHomePhone", objFS.ReadLine
colFormElements.Add "txtemail", objcFS.ReadLine
Search = True
objFS.close
Exit Function
'Else
'strMode = "New"
'colFormElements.RemoveAll
'colFormElements.Add "txtFirstName", strFirstName
'colFormElements.Add "txtWorkPhone", ""
'colFormElements.Add "txtHomePhone", ""
'colFormElements.Add "txtemail", ""
'strDummy1 = objFS.ReadLine
'strDummy2 = objFS.ReadLine
'strDummy3 = objFS.ReadLine
End If
Loop
Search = False
objFS.close
End Function
Private Sub CreateDict
Dim item
For Each item in Request.Form
colFormElements.Add item, Request.Form(item)
Next
End Sub
Public Sub Save
Dim objForm, objFileSystemObject, objFile, objFS
set objFileSystemObject = CreateObject("Scripting.FilesSystemObject")
If Not objFileSystemObject.FileExists(strServerFilePath)
Then
set objFS = objecFileSystemObject.CreateTextFile(strServerFile Path)
else
set objFile = objFileSystemObject.GetFile(strServerFilePath)
set objFS = objFile.OpenAsTextStream(8, -2)
End If
For Each strItem in colFormElements
objFS.WriteLine trim(colFormElements.Item(str.Item))
Next
objFS.Close
set objFS = Nothing
set objFileSystemObject = Nothing
End Sub
'Create a property called Mode
Public Property Get Mode
Mode = strMode
End Property
Public Property Let Mode(newMode)
strMode = new Mode
End Property
'Create a property called ServerPath
Public Property Get ServerPath
ServerPath = strServerFilePath
End Property
Public Property Let ServerPath(newServerPath)
strServerFilePath = newServerPath
End Property
END CLASS
%>