2015-08-11 08:00
采纳率: 0%
浏览 278


I have made a form, which on submit goes to a php file (save.php) and echoes the name back, which after taken as response is alerted in the index.html. Somehow I cannot print back the name which was send to php. Pls help.


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
                    type: "POST",
                    url: "save.php",
                    data: jQuery("#form1").serialize(),
                    cache: false,
                    success:  function(data){
                       /* alert(data); if json obj. alert(JSON.stringify(data));*/

<div class="form_wrapper">
    <form id="form1">
        Name:<input id="name1" type="text" /> <br/>
        Email:<input id="email1" type="email" /><br/>
        <input id="submit1" type="submit" />



$name = $_POST['name1'];
$email = $_POST['email1'];
echo $name;


Kindly, help!


Notice: Undefined index: name1 in C:\xampp\htdocs\example3\save.php on line 3

Notice: Undefined index: email1 in C:\xampp\htdocs\example3\save.php on line 4
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongyong8071
    dongyong8071 2015-08-11 08:09

    Give your input feild a name and access $_POST['given_name'] in php

    Thank you :)

    点赞 评论
  • duanlie7447
    duanlie7447 2015-08-11 08:11

    The thing is that your inputs don't have the name attribute with the name1 and email1.

    Name:<input id="name1" name="name1" type="text" /> <br/>
    Email:<input id="email1" name="email1" type="email" /><br/
    点赞 评论
  • duanliang1019
    duanliang1019 2015-08-11 08:26

    You have missed out the name of the input field

     Name:<input id="name1" type="text" name="name1"/> <br/>
     Email:<input id="email1" type="email" name="email"/><br/>
    点赞 评论