这是前端代码    <!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>表单与PHP交互</title>
</head>
<body>
<!--<form action="http://localhost:63342/htdocs/Service.php" method="get">-->
<form action="http://localhost:63342/htdocs/Service.php" method="post">
      用户名:<input type="text" name="name">
      密  码:<input type="password" name="password">
      <br/>
      <input type="submit" value="提交">
  </form>
</body>
</html>这是php代码
<?php
//echo "用户名:".$_GET['name']."<br>密码:".$_GET['password'];
echo "用户名:".$_POST['name']."<br>密码:".$_POST['password'];
这是报错Notice: Undefined index: name in C:\xampp\htdocs\Service.php on line 3Notice: Undefined index: password in C:\xampp\htdocs\Service.php on line 3
用户名:
密码:

解决方案 »

  1.   

    你简单解决 搞2个页面 
    a页面是表单 提交到action="b.php"
    b页面写echo "用户名:".$_POST['name']."<br>密码:".$_POST['password'];
      

  2.   

    没用,试了,会自动下载Service.php
      

  3.   

    action里面直接写这个大小写都试试Service.php
    接到数据之后用isset判断一下
    isset($_POST['name'])?$_POST['name']:'';
      

  4.   

    直接使用$_POST['name']会报数组索引不存在
    $user_name = '';
    $user_password = '';
    if(isset($_POST['name'])){
    $user_name = $_POST['name'];
    }
    if(isset($_POST['password'])){
    $user_password = $_POST['password'];
    }
    echo "用户名:".$user_name."<br>密码:".$user_password;
      

  5.   

    终于解决了,原来是端口的问题,解决办法,http://ask.csdn.net/questions/171665。这是那个解决办法的帖子,有问题的可以看下,记得如果你用XAMPP的端口要改为http://localhost:80这样就可以了