How to access these variables ? I'm trying to retrieve username and password in php files, But, it says Undefined index username if I use $_POST['Username'}

如何访问这些变量?我正在尝试在php文件中检索用户名和密码,但是,如果我使用$ _POST ['Username'},它会显示未定义的索引用户名

 <script>
    var a = new XMLHttpRequest();
    a.onreadystatechange = function(){
         if (a.readyState==4 && a.status==200) {
              ajaxFinished = true; 
              alert(a.responseText);
         }
         else {
         }                          
    }
    a.open("post","php/psswd.php",true);
    a.send('"Username="+document.getElementByNames("Username")+"&Password="+getElementByNames("Password")'); // posting username and password
 </script>

How to retrieve these fields in php file ?

如何在php文件中检索这些字段?

3 个解决方案

#1


1

I found out the answer myself, the problem was that, a.setRequestHeader("Content-type","application/x-www-form-urlencoded"); needs to be added. And document.getElementsByName('xyz') returns nodeList, but not perticular node, We need to traverse that nodeList.

我自己找到了答案,问题是,a.setRequestHeader(“Content-type”,“application / x-www-form-urlencoded”);需要添加。而document.getElementsByName('xyz')返回nodeList,但不返回特定节点,我们需要遍历那个nodeList。

更多相关文章

  1. 在CSDN下载资源,扣了积分,下载的是一个404页面的html文件
  2. html5结合flash实现视频文件在所有主流浏览器兼容播放
  3. iis aspx常见错误 HTTP 错误 404 - 文件或目录未找到。
  4. 急死我了!我以前用DREAMWEAVER编写的HTML文件突然变成乱码了!!!
  5. html页面输出pdf格式文件(一步步很详细)
  6. commons-fileupload文件上传、下载
  7. Eclipse中以html格式高亮显示velocity文件
  8. 将PHP代码添加到.html文件
  9. 性能权衡 - CSS效率,CSS文件大小,HTML文件大小

随机推荐

  1. Ruby和Python哪个更强大?学习分析
  2. Java面试题全集(12)
  3. 面试官:什么是CSRF?(你的钱为什么被转走,这篇
  4. 2020年5A PMP 经验分享
  5. 静态链表
  6. 栈和队列就是这么简单
  7. 解读容器的 2020:寻找云原生的下一站
  8. JVM中一个小知识点:深堆和浅堆的认识
  9. Linux网络基础概念
  10. 十道简单算法题