Results 1 to 7 of 7

Thread: Activating PHP code with Javascript - Help Please...

  1. #1
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Activating PHP code with Javascript - Help Please...

    Hello,
    Is there a way for me to activate php code on my page - perhaps with a button? Or are there any other methods?

    Thanks

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    I think you should have a look at this resource

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's a very simplified version of "AJAX." See this tutorial for a generally preferable way of doing it -- the XHR object means that it's no longer necessary to bother with the iframe at all.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks for that

    Looking at the tutorials now. Thanks very much!

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Wait. Using JavaScript to load PHP completely eliminates the purpose of PHP. When you write out PHP commands, when the user views the code, all she/he sees is the PHP output. With Javascript you can see all the variables, commands, etc. Doing so would enable a user to view your PHP code.
    I'm thinking these resources may have a security leak.
    - Mike

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You're wrong.

    Certain variables will be revealed to the client, yes, but these needn't be sensitive. If one wished to use Javascript to retrieve the address of a client on demand, for example, one would simply pass the client's name or ID to the PHP script. This is not sensitive information. The PHP script is the only part that touches the sensitive information such as the database access details.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Remember, Javascript only retrieves the visible elements of PHP. It's just like refreshing the page a bunch of times... you get some output, but it's not the secure data inside the PHP code.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •