I have a form which the user enter info. I have 2 buttons - 1 takes data to next page to save data. The other button recalculates and re displays the same page. The problem is I cant read the data in the second form. It is blank. How can I use input data in the 2 forms

Recommended Answers

All 2 Replies

<html>
<head>
<title></title>
</head>
<body>
<?php
// Here you do the calculations, for example + 2
if ($_POST['calculatebutton']) {
$displaydata = $_POST['number'];
$displaydate = $displaydate + 2;
} else {
$displaydata = 0;
}
// The form
echo "
<form>
Number: <input type=\"text\" size=\"1\" name=\"number\" value=\"".$displaydata."\" />
<input type=\"submit\" name=\"sendbutton\" value=\"Send Form\" />
<input type=\"submit\" name=\"calculatebutton\" value=\"Calculate my number into a new one!\" />
</form>
";
?>
</body>

many thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.