Hi guys,
How to retain the form data via redirect page? on the example below when i submit, no form data is passed to either add.php or subtract.php.
How do i solve this problem?
index.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="redirect.php" method = "post">
Number 1: <input type="text" name = "number1"><br>
Number 2: <input type="text" name="number2"><br>
<input type="submit" name = "sel" value="add">
<input type="submit" name="sel" value="subtract">
</form>
</body>
</html>
redirect.php
<?php
switch ($_POST['sel']){
//if we add
case 'add':
header("Location: add.php");
break;
//if we subtract
case 'subtract':
header("Location: subtract.php");
break;
}
//exit;
?>
add.php
<?php
echo $_POST['number1']
." + ". $_POST['number2']." = "
. ($_POST['number1']+$_POST['number2']);
?>
subtract.php
<?php
echo $_POST['number1']
." + ". $_POST['number2']." = "
. ($_POST['number1']-$_POST['number2']);
?>