BryanVest Posted September 7, 2011 Share Posted September 7, 2011 I know the php is basic and not completed yet, but I am working on that. My next step I want the result to show on index.php when a form is submitted to calculator2.php. I just cant seem to get it. Please help! index.php <div class="post"> <h2 class="title">Calculator</h2> <hr /> <form method="post" action="calculator2.php"> Fireplace Front Width: <input type="text" name="fw"> <br /> Fireplace Back Width: <input type="text" name="bw"> <br /> Fireplace Depth: <input type="text" name="fd"> <br /> <input type="submit" name="Submit" value="Submit"> </form> Pounds Of Glass Needed: <?php echo $res1; ?> </div> calculator2.php <?php $frontwidth = $_POST['fw']; $backwidth = $_POST['bw']; $firedepth = $_POST['fd']; $x = $frontwidth + $backwidth+ $firedepth; $y = ($x / 3) * .6667; $res1 = $y *2; echo $res1; ?> Link to comment https://forums.phpfreaks.com/topic/246596-show-form-results-on-same-page/ Share on other sites More sharing options...
voip03 Posted September 7, 2011 Share Posted September 7, 2011 You need to move Pounds Of Glass Needed: <?php echo $res1; ?> to calculator2.php Link to comment https://forums.phpfreaks.com/topic/246596-show-form-results-on-same-page/#findComment-1266304 Share on other sites More sharing options...
voip03 Posted September 7, 2011 Share Posted September 7, 2011 <?php if(isset($_POST['Submit'])) { $frontwidth = $_POST['fw']; $backwidth = $_POST['bw']; $firedepth = $_POST['fd']; $x = $frontwidth + $backwidth+ $firedepth; $y = ($x / 3) * .6667; $res1 = $y *2; echo $res1; echo $frontwidth; } ?> <div class="post"> <h2 class="title">Calculator</h2> <hr /> <form method="post" action="index.php"> Fireplace Front Width: <input type="text" name="fw"> <br /> Fireplace Back Width: <input type="text" name="bw"> <br />Fireplace Depth: <input type="text" name="fd"> <br /> <input type="submit" name="Submit" value="Submit"> </form> Pounds Of Glass Needed: <?php echo $res1; ?> </div> Link to comment https://forums.phpfreaks.com/topic/246596-show-form-results-on-same-page/#findComment-1266305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.