Click to See Complete Forum and Search --> : Urgent Help
sam0010
Feb 3rd, 2001, 06:25 PM
can someone write me a script in any laguage as long as u tell me of a FREE host that the script will run on and how to install it! the script must take 5 values from a form and post them in a text file seperated by commas and and like so:
value1,value2,value3,value4,value5
value1,value2,value3,value4,value5
every submittin is on a new line so if the submit a full form than an empty form then a full form the text file would look like this:
value1,value2,value3,value4,value5
,,,,
value1,value2,value3,value4,value5
that should be simple! however it get a bit complicated
when the form is submitted it searches all the valueones for a match with the valueone being submitted. if there is a match the line that contains the OLD valueone in the textfile get deleted and the NEW line is added to the text file.
if you have any questions PLEASE post them i really need this script as soon as possible! thanx in advanced!
Reward if successful!!
sam0010
Feb 5th, 2001, 03:33 PM
REWARD FOR SUCCESS
Xenonic_Rob
Feb 11th, 2001, 02:40 PM
OK, I might be able to help you Sam, but first, does it expressly need to be a text file? Can it be an Access database?
sam0010
Feb 12th, 2001, 09:56 PM
It can be anything! but a text file would be better do u think u can do it sorry but i dont got the reward anymore!
Xenonic_Rob
Feb 13th, 2001, 12:09 PM
Mmm... let me see what I can do.
What's the deadline?
sam0010
Feb 13th, 2001, 02:56 PM
the sooner the better thanx for your help! it shouldent be too hard
sam0010
Feb 13th, 2001, 02:57 PM
it would be nice if the number of values wasnt fixed i could use this script for more than one thing!
thanx again for all your help
sam0010
Feb 15th, 2001, 02:31 PM
hi just wanted to know how the script is goin
again tanx alot
sam0010
Feb 19th, 2001, 05:24 PM
Hello whats going on
Jerry Grant
Feb 20th, 2001, 09:34 AM
I have written some script which should address your request.
It's a bit untidy but gives you the basis of what you require:
Create a HTML page called Inputs.htm and paste in the following code:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Input data into the text boxes....</TITLE>
</HEAD>
<SCRIPT Language="JScript">
<!--
var inprogress;
function DoSubmit(sessionid)
{
if (inprogress == "True")
{
alert("Submission is being processed, please wait");
return (false);
}
inprogress = "True";
window.location.href="Process.asp?T1="
+ oForm.oText1.value
+ "&T2=" + oForm.oText2.value
+ "&T3=" + oForm.oText3.value
+ "&T4=" + oForm.oText4.value
+ "&T5=" + oForm.oText5.value;
}
-->
</SCRIPT>
<BODY>
<FORM name="oForm">
<P>
<TABLE cellSpacing=2 cellPadding=2 border=0>
<TR>
<TD>Input No 1 </TD>
<TD><INPUT id=text1 name=oText1></TD>
</TR>
<TR>
<TD>Input No 2 </TD>
<TD><INPUT id=text2 name=oText2></TD>
</TR>
<TR>
<TD>Input No 3 </TD>
<TD><INPUT id=text3 name=oText3></TD>
</TR>
<TR>
<TD>Input No 4 </TD>
<TD><INPUT id=text4 name=oText4></TD>
</TR>
<TR>
<TD>Input No 5 </TD>
<TD><INPUT id=text5 name=oText5></TD>
</TR>
</TABLE></P>
<INPUT type="button" style="width:75px" value="Submit" onclick="DoSubmit()"></INPUT>
<FORM>
</BODY>
</HTML>
Create an ASP page called Process.ASP and paste in the following code:
<html>
<title>Processing data from Inputs.htm</title>
<BODY>
<%@ Language=VBScript%>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim sData
Dim iFile '== Input File
Dim oFile '== Output File
Dim TextStream
Dim sLine '== File line
Dim updateFlag
Dim sSplit
updateFlag = 0
sData = Request.QueryString("T1") & "," & _
Request.QueryString("T2") & "," & _
Request.QueryString("T3") & "," & _
Request.QueryString("T4") & "," & _
Request.QueryString("T5")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("C:\myData.html") Then
Set iFile = fso.GetFile("C:\myData.html")
Else
Set iFile = fso.CreateTextFile("C:\myData.html", True)
iFile.WriteLine("'=== Input Data file ==='")
iFile.Close
Set iFile = fso.GetFile("C:\myData.html")
End If
Set TextStream = iFile.OpenAsTextStream(ForReading)
'=== Create a temporary file to put data into
Set oFile = fso.CreateTextFile("C:\myTemp.html", True)
Do While Not TextStream.AtEndOfStream
'=== Get the next line from the file
sLine = TextStream.ReadLine
Select Case sLine
Case "'=== Input Data file ==='"
Response.Write "<font color='Blue'>" & sLine & "</font><br>"
oFile.WriteLine sLine
Case ""
'=== Enter whatever lines you want to ignore in separate expressionlists
Case Else
sSplit = Split(sLine, ",")
'=== Check the first item for a duplicate
If Trim(sSplit(0)) = Trim(Request.QueryString("T1")) Then
Response.Write "<font color='Red'>" & sData & "</font><br>"
oFile.WriteLine sData
updateFlag = 1
Else
Response.Write sLine & "<br>"
oFile.WriteLine sLine
End If
End Select
Loop
TextStream.Close
'=== If the record was not found in the file then add it now
If updateFlag = 0 Then
Response.Write "<font color='Red'>" & sData & "</font><br>"
oFile.WriteLine sData
End If
Response.Write "<font color='Blue'>The item in red represents a new entry or updated existing item.</font><br>"
oFile.Close
fso.CopyFile "C:\myTemp.html", "C:\myData.html", True
fso.DeleteFile "C:\myTemp.html", True
Set fso = Nothing
%>
</BODY>
</HTML>
Put both files into a IIS folder, then call the Inputs.htm.
You can improve this if you use Server.MapPath("myData.htm") so you can get to the file from a remote server
Is this all understandable? Let me know how you get on!
:cool:
sam0010
Feb 25th, 2001, 01:23 PM
thank you so much!!!!!!!! i havnt tryed it yet i just got my connection back (stupid cable service) ill tell u how it goes! do i have to upload this to a cgi accepting host or does it matter?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.