php - XMLHttpRequest Error in passing value on url -


here have 2 fields: name & password. have been trying echo value using xmlhttprequest, when click submit, shows name , not password. please me find have gone wrong.

------------index.html--------------

<html> <head> <title>fist ajax application</title> <script type="text/javascript"> function test(){ var xmlhttp;     if(window.xmlhttprequest){         xmlhttp = new xmlhttprequest();          }else{               xmlhttp = new activexobject("microsoft.xmlhttp");     }  var uname = document.getelementbyid('username').value; var upassword = document.getelementbyid('userpassword').value;      xmlhttp.onreadystatechange = function(){         if(xmlhttp.readystate==4){             document.getelementbyid('results').innerhtml = xmlhttp.responsetext;             }      } url = "testform.php?name="+uname+"&password="+upassword; xmlhttp.open("get",url,true); xmlhttp.send();  } </script> </head>  <body> <table border="1">   <tr>     <td>name:</td>     <td><input type="text" name="name" id="username" /></td>   </tr>   <tr>     <td>password</td>     <td><input type="text" name="password" id="userpassword" /></td>   </tr> </table> <input type="button" value="suubmit" onclick="test()" /> <p><div id="results"> results...</div></p>    </body> </html> 

-----------------testform.php---------------

<?php  $name = $_get['name']; $password = $get['password'];  echo $password."<br />"; echo $name."<br />";   ?> 

use $password = $_get['password']; instead of $password = $get['password'];


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -