Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts

    Referencing PHP inside of Javascript (or the other way around)

    all,

    i have a large PHP script that gives me a report online. i need to reference a couple of controls on the that are on the page while the script is running. example, I have these two inputs:
    PHP Code:
    <input type="text" name="username" id="username" />
    <
    input type="text" name="Password" id="Password" /> 
    i really need to reference those value in the PHP I wrote, but I just can't seem to find a way to make it work. the page has a PHP extension. i'm also open to ideas of writing the PHP inside of a JS function, if it's even possible. ideas anyone? thanks!

  • #2
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    So basically you need to reference the values a user inputs in those text boxes, without the use of forms? Or am I missing something?
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #3
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Zangeel View Post
    So basically you need to reference the values a user inputs in those text boxes, without the use of forms? Or am I missing something?
    no you're not missing something. i wasn't clear though about what I want. basically I want a login form to validate the identity of the visitor before they view the tables that the PHP writes to the webpage. does that make sense?

    so in short:
    *if login valid, form disappears, script runs and log is written
    *if login invalid, message and clear the form

  • #4
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    If you know your way around javascript most of that is easy, referencing a php script with javascript is AJAX. So you can grab the values they input, check if the login is valid, do any other voodoo magic you want in your php script, and then send the data back to the page you're on.

    I explained the ins and outs of ajax here: Easy nav

    Scroll down to my long post.

    Is that something you need? AJAX?
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • #5
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Zangeel View Post
    If you know your way around javascript most of that is easy, referencing a php script with javascript is AJAX. So you can grab the values they input, check if the login is valid, do any other voodoo magic you want in your php script, and then send the data back to the page you're on.

    I explained the ins and outs of ajax here: Easy nav

    Scroll down to my long post.

    Is that something you need? AJAX?
    if this logic is true.....AJAX = PHP inside JAVASCRIPT....then yes, AJAX is exactly what I need to learn. why?

  • #6
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    AJAX Is basically referencing a script or external page while running another script (the page you're on) so you can pass variables to php, and return a result without changing a page. The basics are in that post.
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]


  •  

    Posting Permissions

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