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.
HTML
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#submit1').click(function(){
$.ajax({
type: "POST",
url: "save.php",
data: jQuery("#form1").serialize(),
cache: false,
success: function(data){
/* alert(data); if json obj. alert(JSON.stringify(data));*/
alert(data);
}
});
});
});
</script>
</head>
<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" />
</form>
</div>
</body>
</html>
PHP:
<?php
$name = $_POST['name1'];
$email = $_POST['email1'];
echo $name;
?>
Kindly, help!
ERROR:
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