(1)write code for form.html file:-
<!doctype html>
<html lang="en">
<head>
<title>passing form input value to php - BY OM SIR</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function (event) {
// triggered when the form submitted
$("#myform").submit(function(event) {
event.preventDefault();
$("#response").empty();
$.ajax({
// URL to move the uploaded image file to server
url: "pass.php",
// Request type
type: "POST",
// To send the full form data
data: new FormData(this),
contentType: false,
processData:false,
// UI response after the file upload
success: function(data)
{
$("#response").html(data);
}
});
});
// Triggered when the image changed (browse)
// Function to show the image as a preview
});
</script>
</head>
<body>
<label>passing form data to php file </label>
<form id="myform" action="" method="post" enctype="multipart/form-data">
<input type=text name=myname>
<input type="submit" value="pass" />
</form>
<div id="response"> </div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<title>passing form input value to php - BY OM SIR</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function (event) {
// triggered when the form submitted
$("#myform").submit(function(event) {
event.preventDefault();
$("#response").empty();
$.ajax({
// URL to move the uploaded image file to server
url: "pass.php",
// Request type
type: "POST",
// To send the full form data
data: new FormData(this),
contentType: false,
processData:false,
// UI response after the file upload
success: function(data)
{
$("#response").html(data);
}
});
});
// Triggered when the image changed (browse)
// Function to show the image as a preview
});
</script>
</head>
<body>
<label>passing form data to php file </label>
<form id="myform" action="" method="post" enctype="multipart/form-data">
<input type=text name=myname>
<input type="submit" value="pass" />
</form>
<div id="response"> </div>
</body>
</html>
(2)write code for pass.php file:
<?php
$myname=$_POST['myname'];
echo $myname;
?>
advance coding knowledge for fresher
ReplyDeletefollow us for same services https://sisgain.com/angular-js-development