Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 this does not work ? Why

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-09 : 08:04:18
[code]if left(request.Form("phone_nu"),3) = "234" and len(request.Form("phone_nu")) < 11 then
response.Redirect("sms.asp?error="&(request.Form("phone_nu")))
end if[/code]

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-06-09 : 08:15:24
No idea, because you didn't explain what "this does not work" means. Does it cause an error? Does it not redirect? Does it redirect to the wrong page? Does the redirection page throw an error? Does the redirection page not function properly for the parameters passed? Or does nothing happen at all?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-09 : 08:18:39
try this:
i think you have extra ( )

if Left(Request.Form("phone_nu"),3) = "234" and Len(Request.Form("phone_nu")) < 11 then
Response.Redirect("sms.asp?error=" & Request.Form("phone_nu"))
end if


Go with the flow & have fun! Else fight the flow
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-09 : 08:18:49
try this:
i think you have extra ( )

if Left(Request.Form("phone_nu"),3) = "234" and Len(Request.Form("phone_nu")) < 11 then
Response.Redirect("sms.asp?error=" & Request.Form("phone_nu"))
end if


Go with the flow & have fun! Else fight the flow
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-09 : 09:18:09
thanks but it just doesnt work.

No error, but when i put a phone number starting with 234 and less than 11 characters, it still doesnt see the error.

would keep at it, anyway

thanks
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-06-09 : 09:20:59
step #1 is to always make sure your page is successfully receiving the values from the form.

Are you SURE that Request.Form("...") is returning the values you expect?

- Jeff
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-09 : 09:45:26
Sure Jeff.

Basically its an sms portal, that receives phone numbers and passes them to my providers site doing a loop.

I am trying to guard against users, who dont finish typing the phone numbers in full of which we have many such examples.

The values are all saved into our db, either successful or failure. So the values are correct.

I even did a response.write to check the values being passed accross.

If i take of the first argument it works well. ie

if  Len(Request.Form("phone_nu")) < 11 then 
Response.Redirect("sms.asp?error=" & Request.Form("phone_nu"))
end if



But this value is basically for my country, so thats the reason for adding the second condition, the
 if 234
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-06-09 : 10:01:03
Are you inadvertantly counting spaces at the end of the number...even when it's not filled out to the 11???
break the IF condition down...and see which bit is failing.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-09 : 10:48:22
break down how ?

This works
quote:
if Len(Request.Form("phone_nu")) < 11 then
Response.Redirect("sms.asp?error=" & Request.Form("phone_nu"))
end if


but adding the full code doesnt work
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-09 : 14:38:28
thanks all,
i got it to work

CODE:
[CODE]

Dim strNum
strNum = Trim(Request.Form("phone_nu"))

if left(strNum, 3) = "234" and len(strNum) < 11 then
Response.Redirect("sms.asp?error=" & strNum)
end if[/CODE]
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-06-09 : 16:43:45
Didn't we go over this before?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50512

- Jeff
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-10 : 03:33:46
quote:
Originally posted by jsmith8858
Didn't we go over this before?


hi Jeff,
its a different context, this script just checks to see if the phone numbers that originate from Nigeria are more than 11 characters.

The previous, was a question about trim function.

However both run in the same page.

:-)
Go to Top of Page
   

- Advertisement -