Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POST ASP data doesn't stop sending!

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi,

I have built an application that takes a mobile number and message passed by querystrings, then does some tests and if the number is not found in the database it checks another table and sends some results.

Problem i have is that it keeps posting data. the results are correct when i response.write them and when i get the SMS but my posting method keeps sending so the SMS message dont stop!! Can anyone see an issuewith my code as it does work but i think this bit might be the problem.

Any help would be great. Thank you in advance.

Code:
				set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
				xmlhttp.Open "POST","[URL unfurl="true"]http://www.test.com/submitmsg.cgi?UN=sc@test.co.uk&PIN=werrw&N="&SenderMobileNumber&"&M="&SMSResults&"",false[/URL]
				xmlhttp.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
				xmlhttp.send DataToSend


The code below is used to post data to a partner who then sends out the SMS message.

Based on the results from my query "qryAvailabilityCheck" There i wll always be 3 results passed to variable "SMSResults" then that goes to my post method "ServerXMLHTTP"


Results for var "SMSResults" would be like:

propertyname Phone and propertytype
propa 020833333 bb
propb 020844444 h
propc 020855555 g



Code:
<%@ Language=VBScript %>
<!--#include file="includes/connection.asp"-->

<%
	'number from icetrak
	SenderMobileNumber =  Request.QueryString("SenderMobileNumber")
	'remove 44 from number to test in database
	CleanSenderMobileNumber = (Replace(SenderMobileNumber,"44",""))
	'message text from icetrak
	MessageText = Request.QueryString("MessageText")
	
	qryCheckNumber = "SELECT mobilephone, EmailAddress, contact FROM wce_contact WHERE idstatus = 'Property' AND mobilephone LIKE '%"& CleanSenderMobileNumber &"%'"
	Set oRsSelect = connStr.Execute(qryCheckNumber)
	
	'response.write(qryCheckNumber)
	'response.end
	
	Do While Not oRsSelect.eof	
	
		SenderMobileNumberChecked = oRsSelect("mobilephone")
		SenderEmailAddress = oRsSelect("emailaddress")
		SenderName = oRsSelect("contact")
		
	oRsSelect.MoveNext
	Loop
	
	'If SenderMobileNumberChecked = "" Then
		
'Check to see if number exsits
If SenderMobileNumberChecked <> "" Then
	
		'The number has been checked and found in the database, now update the database if the MessageText contains a 1 or 0 else terminate the operation
		If MessageText = "1" OR MessageText = "0" Then
		
		Rooms = (MessageText)

		qryUpdateOwnerAvalibility = "UPDATE wce_contact SET rooms = '"& Rooms &"' WHERE mobilephone = '"& SenderMobileNumberChecked &"'"
		Set oRsUpdateOwnerAvalibility = connStr.Execute(qryUpdateOwnerAvalibility)

		Set JMail = Server.CreateObject("JMail.SMTPMail")
		JMail.ServerAddress = "213.129.68.170"
		JMail.Sender = "support@textrooms.co.uk"
		JMail.Subject = "Text Rooms Update"
		JMail.AddRecipientEx (SenderEmailAddress),(SenderName)
		JMail.Body = "Thank you for updating your room availability!" 
		JMail.Execute
		JMail.Close()


		End If
		
Else
		
			'the number is not in the database so search for the postcode or phone number then pass back the results to Enquiries
			SenderMobileNumberChecked = (SenderMobileNumber)
			'response.write(SenderMobileNumberChecked)
			'response.end
			MessageTextPcodeorPhone = MessageText		
			
			qryAvailabilityCheck = "SELECT Top 3 propertyname, type, phone, postcode FROM wce_contact WHERE Rooms = '1' AND (Postcode <> '' OR phone <>'') AND idstatus = 'Property' AND (Postcode LIKE '%"& MessageTextPcodeorPhone &"%' OR phone LIKE '%"& MessageTextPcodeorPhone &"%') ORDER BY NEWID()"	
			Set oRsAvailability = connStr.Execute(qryAvailabilityCheck)			

			'response.write(qryAvailabilityCheck)
			'response.end

			SMSResults = ""
			thisResult = ""

				Do While Not oRsAvailability.eof	

					'Items to send to Enquiries
					propertyname = oRsAvailability("propertyname")
					PropertyType = oRsAvailability("type")
					phone = oRsAvailability("phone")

					thisResult = propertyname &" "& phone &" "& propertytype
					SMSResults = SMSResults & thisResult&"-"

					'response.end

				oRsAvailability.MoveNext
				Loop

			'response.write(SMSResults)
			'response.end

				dim xmlhttp 
				set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
				xmlhttp.Open "POST","[URL unfurl="true"]http://www.test.com/submitmsg.cgi?UN=sc@test.co.uk&PIN=werrw&N="&SenderMobileNumber&"&M="&SMSResults&"",false[/URL]
				xmlhttp.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
				xmlhttp.send DataToSend


End If	

	
%>
 
could there be something wrong on the partner's end - i.e. they have some sort of an infinite loop that keeps sending messages?



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Thanks for the reply. No Can't be that they are a very big outfit and have had this software going for years. It must be somethig my end. I have tried killing the variables at the end of the statememnt but that doesn't seem to work either.

I will keep testing sure it will become apparent.
 
is this:


your partner's url? I know it's not the real one, but is it your CGI script or your partners?

Also, how many lines do you have in "SMSResults" - are you trying to send one message to each person you retrieve or simply sending it out to the first one in the list?



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Hi, It is our partners cgi script. I just pass to querysting items one is the mobile number so they know who to forward it too. And the other is 1 string of 3 properties there are no intentional line breaks.

You got some ideas?
 
probably a long shot - very long shot, but without seeing the documentation from the sender, just randomly picking out things...

also try a response.end at the very end (after the xmlhttp is set to nothing)

Code:
dim xmlhttp 
[b]if session("msgSent") <> "YES" then[/b]
                set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
                xmlhttp.Open "POST","[URL unfurl="true"]http://www.test.com/submitmsg.cgi?UN=sc@test.co.uk&PIN=werrw&N="&SenderMobileNumber&"&M="&SMSResults&"",false[/URL]
                xmlhttp.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
                xmlhttp.send DataToSend
[b]xmlhttp.close[/b]
[b]set xmlhttp = nothing[/b]
[b]session("msgSent") = "YES"[/b]
[b]end if[/b]

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Thanks, Looks like a ray of hope :) will try anything, can't access the server until tomorrow though, will keep you posted.

There is no documentation from the partner as it is very simple they told me over the phone. They pass to query values a mobile number formated 4498798798 and the message which will be a postcode nw1 for example and i pass the number back in and the the message i want them to see which could just be a single word.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top