Including Javascript variables into PHP?

Discussion in 'PHP' started by Handsofmodder, Aug 11, 2008.

  1. #1
    Is it possible to insert variables from your javascript variable into your PHP variable?
     
    Handsofmodder, Aug 11, 2008 IP
  2. Property_Control

    Property_Control Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could set the variable as a cookie in JS, but it wouldn't work too well
     
    Property_Control, Aug 11, 2008 IP
  3. skript

    skript Active Member

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #3
    PHP is a server side scripting language and javascript is a client side one. This means the php code executes itself on the server and the javscript code executes on your computer.
    This mens that you cannot insert javascript variables into the php script that has already executed.
    You can insert javascript variables into a php script by GET or POST through XMLHttpRequest (XHR). This way you can get a response from your PHP script without leaving the page.
     
    skript, Aug 11, 2008 IP
  4. Handsofmodder

    Handsofmodder Peon

    Messages:
    177
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I just wanted to know because I want to create a dyanamic website, and I was hoping to include some sort of text editor so my visitors can post articles. Does anyone have any suggestions?
     
    Handsofmodder, Aug 11, 2008 IP
  5. skript

    skript Active Member

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #5
    skript, Aug 11, 2008 IP