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.
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
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
%>