Web Programming Training By OM SIR Call for free Demo :9320957717/18

Jquery example form to php passing form value

(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").on('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;

?>




Previous
Next Post »

1 comments:

Write comments
Garima Ahuja
AUTHOR
23 October 2017 at 01:51 delete

advance coding knowledge for fresher
follow us for same services https://sisgain.com/angular-js-development

Reply
avatar