write post function php code example
Example 1: how to send post variables in header php
<form name="myform" action="" method="post">
<p>Name</p>
<input type="text" name="name" value="" />
<span class="warning"><?php if (isset($errors['name'])) echo $errors['name']; ?> </span>
<p>Employer</p>
<input type="text" name="employer" value="" />
<span class="warning"><?php if (isset($errors['employer'])) echo $errors['employer']; ?> </span>
<input name="somename" type="hidden" value="somevalue"/>
<input type="submit" value="send">
</form>
Example 2: php receive post
$.ajax({
type: "POST",
url: 'example.php',
data: { "num1": 1, "num2": 2},
contentType: "application/json; charset=utf-8",
dataType: "JSON",
async: false
})
$num1 = $_POST["num1"];
$num2 = $_POST["num2"];
$sum = $num1 + $num2;
echo $sum;