You can achieve this by using ajax. For example once a person is done filling in a form, they can press a button. Then you set up a click listener for this button and execute the ajax call. The ajax method will send data to the php script and the php script will run, then return whatever you set it to return to the ajax method without reloading the page and you will be able to manipulate the result in whatever way you please. For example,
Your form submit button;
<button id="submit">Submit Form</button>
Your javascript listener and ajax method;
//This is executed whenever the submit buttom is clicked.
$( "#submit" ).bind( "click", function() {
var myVar="Test Variable";
$.ajax({
type: 'POST',
url: "get_message.php",//your php script
data: {myVar:myVar},//your variable
success: function(result){
alert(result);
}
})
})
Your php script which i called get_message.php
<?php
$var = $_POST['myVar'];//get sent variable from ajax using post method
echo "The sent string is " . $var;
?>
This should then output The sent string is Test Variable
.
Let me know if this answer helps you or you have any problems. Please note that i you have to include jquery for the code to work.