Solved

HTTP Post via URL

Posted on 2016-08-22
4
18 Views
Last Modified: 2016-09-23
I have the below code i have been using for ages, that long that ive forgotten how to submit information via a URL to it rather than through an app.

Can anyone let me know what i have to type to get info out on the other end please.


<%
Dim TN,FN,SN,TL,EM,PC,NT,CT,ES,RV,LT,TT,AT,RF, stext

Dim fs, file

fs=Server.CreateObject("Scripting.FileSystemObject")
file=fs.CreateTextFile("C:\test\upload\" & request.form("Reference") & ".txt",true)

TN = request.form("TradingName")
FN = request.form("firstname")
SN = request.form("surname")
TL= request.form("Tel")
EM = request.form("Email")
PC = request.form("PostCode")
NT = request.form("Notes")
CT = request.form("CompanyType")
ES = request.form("Established")
RV = request.form("Revenue")
LT = request.form("LeadType")
TT = request.form("TTD")
AT = request.form("ATV")
RF = request.form("Reference")

AT = Replace(AT, "#"  , "")
AT = Replace(AT, """"  , "")
AT = Replace(AT, "£"  , "")
AT = Replace(AT, "&quot;", "")
AT = Replace(AT, "&lt;"  , Chr(60))
AT = Replace(AT, "&gt;"  , Chr(62))
AT = Replace(AT, "&amp;" , Chr(38))
AT = Replace(AT, "&nbsp;", Chr(32))

file.write("""")
file.write(TN)
file.write(""",""")
file.write(FN)
file.write(""",""")
file.write(SN)
file.write(""",""")
file.write(TL)
file.write(""",""")
file.write(EM)
file.write(""",""")
file.write(PC)
file.write(""",""")
file.write(NT)
file.write(""",""")
file.write(CT)
file.write(""",""")
file.write(ES)
file.write(""",""")
file.write(RV)
file.write(""",""")
file.write(LT)
file.write(""",""")
file.write(TT)
file.write(""",""")
file.write(AT)
file.write(""",""")
file.write(RF)
file.write("""")


file.close
file=nothing
fs=nothing
 %>

Open in new window

Post Completed
0
Comment
Question by:CaptainGiblets
  • 2
4 Comments
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 500 total points
ID: 41765513
>Can anyone let me know what i have to type to get info out on the other end please.

Where you see request.form("some_name") that is a form field name that has to be posted.

As example
file=fs.CreateTextFile("C:\test\upload\" & request.form("Reference") & ".txt",true)

Open in new window


refers to a file and that file has a name that you provide via the form field called, "Reference".  If the reference field is submitted as "abc_test" then the code would look for C:\test\upload\abc_test.txt.
0
 
LVL 6

Author Comment

by:CaptainGiblets
ID: 41765527
the code works, we have a 3rd party sending us information on a daily basis, however i need to make some changes to the coding to remove quote marks, i am sure i used to test what information came through by typing in the URL and then ?reference=123456&firstname=Testing

however this is currently just bringing up a blank file.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 41765543
That's correct.  The code is looking for a form post (request.form).  If you used ?reference=123456&firstname=Testing the page would need to change from request.form to request.querystring.

Recreate a form with those form field names and post to that page to test.

I suggest a function to clean remove your quotes.  Then instead of
TN = request.form("TradingName")

Open in new window

you can use
TN = function clean_html(request.form("TradingName"))

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Introduction and Prerequisites This article describes methods for detecting whether a client browser accepts and returns HTTP cookies and whether the client browser runs JavaScript.  Most client browsers will, by default, be configured to use cooki…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now