Check javascript status

Discussion in 'PHP' started by madura99, Oct 8, 2007.

  1. #1
    Hi friends,

    I'm developing a web site using php/mysql (www.lankacarsale.com) and I want to validate all user inputs from client side using javascripts without using server side validation. And want to print a message in html format if user has disabled javascript in the browser. :)

    I jst want to knw what kinda function available in PHP to check javascript status in client browser :confused:

    or do you have any idea except server side validation :D

    same time give your ideas to improve the value of my site (if you have time :p)
     
    madura99, Oct 8, 2007 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Generate the form with javascript, so if the user doesn't have JavaScript enabled, he will not see the form.

    I don't like this solution, and I don't like client side verification (only) too, my advice is that you do both client and server side verification with an html form...
     
    nabil_kadimi, Oct 8, 2007 IP
  3. ziogas

    ziogas Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    use html (not xhtml) tag, inside the headers. <noscript>there is message if browser don't support js</noscript>

    or you can try to search in $_SERVER array, or get_browser() function.
     
    ziogas, Oct 9, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    There's n way to find that out with PHP alone. Not with $_SERVER or get_browser() either.

    However, depending on what you want to do with the user submitted data, it can be very insecure not validating it. And you really can't rely on Javascript for such things.
     
    nico_swd, Oct 9, 2007 IP
  5. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Do not ever trust data from the client! Ever!!
     
    matthewrobertbell, Oct 9, 2007 IP
  6. zenglider

    zenglider Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    There's really no way to check if a user has javascript turned on or off when they visit your site. You could put a bug in the noscript tags that will flip a switch in a database but it wont happen until they visit the site.

    I think your idea to validate user input using only javascript is terrible and very insecure. Never trust user input period! I can get around javascript validation very easy using Firebug for Firefox. Always validate the data server side and use javascript to help "guide" the user as to how you want the data input.
     
    zenglider, Oct 9, 2007 IP