<?php
if(isset($_POST['submit']))
{
$a = $_POST['a'];
$b = $_POST['b'];
$temp = $a;
$a = $b;
$b = $temp;
}
?>
<form method="post">
<h1>SWAP VALUES USING PHP</h1>
Value A: <input type="text" name="a"><br>
Value B: <input type="text" name="b"><br>
<input type="submit" name="submit" value="Swap">
</form>
<?php
if(isset($_POST['submit']))
{
echo "After swapping: <br>";
echo "Value A: ".$a."<br>";
echo "Value B: ".$b."<br>";
}
?>