4 Replies Latest reply on Aug 29, 2015 6:53 PM by revdave

    Javascript newbie login question

    revdave Level 1

      Hi all,

       

      I have some experience with php and now I am trying to convert some things to java script ( js newbie)

       

      So I am trying to create a simple login setup where:

       

      login.html

      - has simple login and password form

       

      then - pass this info to an external php site that processes the request and can return the result back to the login.html (non php) page

       

      ----

      html page...

       

      ?????<form action="mysite.com/logcheck.php" method="post"> << offsite---------

      <input name="login" type="text" value="">

      <input name="pass" type="text" value="">

      <input name="submit" type="submit" value="submit">

      </form>


      --- this goes offset and the php works ok and wraps the result in print_r (json_encode($output));


      but that does NOT come back to the html page


      ----


      I know if I use a javascript get

      $.get("http://mysite.com/logcheck.php", function(data, status){ xxxxxxxxxxx

      .... on a page it will go out and come back with the result....


      BUT how do I use this with a form in html that will grab the form data and send it out?


      confused since javascript can't see GET OR POST - so there must be a better way to do this.........



      Hope I made myself clear.... if not happy to re-explain





        • 1. Re: Javascript newbie login question
          Nancy OShea Adobe Community Professional & MVP

          So I am trying to create a simple login setup where:

           

          login.html

          - some login and password form

           

          that can pass this info to an external php site that processes the request and can return the result back to the login.html (non php) page

           

           

          I'm sorry, you completely lost me...  It's been a long day and a very hot one.

          Can you elaborate a bit more?

           

          Nancy O.

          1 person found this helpful
          • 2. Re: Javascript newbie login question
            revdave Level 1

            Hi Nancy - you are Sooooooo quick!

             

            I submitted to early by accident - I hope this makes more sense now...

             

            basically I want HTML LOGIN FORM PAGE 1 to submit to external PHP page and come back to HTML page with the result

             

            just don't know how to submit the form using javascript so the result come bak in json.....

            • 3. Re: Javascript newbie login question
              revdave Level 1

              i just found this on the web ----- might be a good start

               

              I will maybe turn it into a son 'get' and see if that works.....

               

               

               

               

              <HTML>

              <HEAD>

              <TITLE>Test Input</TITLE>

              <SCRIPT LANGUAGE="JavaScript">

              function testResults (form) {

                  var TestVar = form.inputbox.value;

                  alert ("You typed: " + TestVar);

              }

              </SCRIPT>

              </HEAD>

              <BODY>

              <FORM NAME="myform" ACTION="" METHOD="GET">Enter something in the box: <BR>

              <INPUT TYPE="text" NAME="inputbox" VALUE=""><P>

              <INPUT TYPE="button" NAME="button" Value="Click" onClick="testResults(this.form)">

              </FORM>

              </BODY>

              </HTML>

              • 4. Re: Javascript newbie login question
                revdave Level 1

                Thanks much Nancy...

                 

                Hi this seems to work well for a starter....

                 

                so the form above is cool and I added the $.get inside the function......

                 

                 

                So I will keep working with this....

                 

                 

                <SCRIPT LANGUAGE="JavaScript">

                function testResults (form) {

                    var TestVar  = form.login.value;

                  var TestVar2 = form.pass.value;

                   // alert ("You typed: " + TestVar + TestVar2);

                 

                 

                  $.get("http://gohere.com/login.php add Testvar etc. here.......", function(data, status){ xxxxxxxxxxxxxxx