SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    this does not work ? Why

    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

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is happening -- do you get an error? Is it not redirecting?
    in1.com | Bootply - Bootstrap playground

  3. #3
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Looks fine to me. One possibility is removing the "" from around 234.

  4. #4
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One thing which looks slightly strange to me is this part of response.redirect:

    Code:
    (request.Form("phone_nu"))
    I don't know why you should enclose the request.form itself with brackets? If that's correct, could anybody explain the reason to me? Still an asp beginner myself.

  5. #5
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Good point, I didn't even look at the response.redirect line

  6. #6
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really dont think its the 234 or "234"
    'cause thats based on int value, not a string.

    I dont get an error, it just doesnt work

    It works if i leave it as

    if len(request.Form("phone_nu")) < 11 then
    response.Redirect("sms.asp?error="&(request.Form("phone_nu")))
    end if

  7. #7
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Did you response.write request.form("phone_nu") just to verify the value? It obviously is not matching to "234" so there is either an extra space in the value, or you are comparing a int to a string.

  8. #8
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I keep getting this erro on sitepoints site. Am looking were to report it, 'cause i have to keep refreshing the page

  9. #9
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you response.write request.form("phone_nu") just to verify the value? It obviously is not matching to "234" so there is either an extra space in the value, or you are comparing a int to a string.
    Yes, but thats not the error. It works if i remove the left() function

  10. #10
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried something like this:

    Code:
    strTest = left(request.form("phone_nu"),3)
    response.write = strTest

  11. #11
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok
    I would test all values in my request object and see what i get

    BRB

  12. #12
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Do you want to only see the error if the length is less than 11 AND the first three positions are 234? Or do you want to see the error if the length is less than 11 OR if the first three positions are 234? If it's the second case, your code will not work.

    If you want option one, try this:
    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
    If it's option two you want, try this:
    Code:
    Dim strNum
    strNum = Trim(Request.Form("phone_nu"))
    
    if left(strNum, 3) = "234" or len(strNum) < 11 then
     Response.Redirect("sms.asp?error=" & strNum)
    end if
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  13. #13
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, am trembling at your avatar.....


    .......signed out of sitepoint
    Attached Images Attached Images

  14. #14
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just joking, pls give me a minute to try it out

    Afrika

  15. #15
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi DaveMaxell,

    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
    this works very well.

    I have tested thoroughly, its ok.

    rgds
    Afrika

  16. #16
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi
    Originally posted by c2uk
    One thing which looks slightly strange to me is this part of response.redirect:


    Code:
    (request.Form("phone_nu"))

    I don't know why you should enclose the request.form itself with brackets? If that's correct, could anybody explain the reason to me? Still an asp beginner myself.
    its just called delimiters in programming, whatever you enclose coudl work as a unit, its just makes it neater.

    e.g. in SQL you could use () or '' to enclose a string

    hope u do understand

  17. #17
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the explanation, I think I know what it does now, still it looks strange to me, at least in this context.

  18. #18
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    many things are strange to me, That a computer can read and understand my script

    amazes me


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •