Skip to content

Instantly share code, notes, and snippets.

@trevorgreenleaf
Created May 12, 2016 17:36
Show Gist options
  • Save trevorgreenleaf/8695d91855b3e3592fdc920623c1b4cf to your computer and use it in GitHub Desktop.
Save trevorgreenleaf/8695d91855b3e3592fdc920623c1b4cf to your computer and use it in GitHub Desktop.
<?php get_header();
/*
Template Name: Calculate Page
*/
if(isset($_POST['submit'])){
$amount = $_POST['amount'];
$price = $_POST['price'];
$total = $amount * $price;
}
if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1>How much will you make</h1>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<div class="col-xs-7">
<form class="form-horizontal" action="" method="POST">
<div class="form-group">
<label for="amount" class="col-sm-2 control-label">Amount:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="amount" value="<?php echo (isset($_POST['amount'])) ? $_POST['amount'] : ''; ?>" id="amount" placeholder="">
</div>
</div>
<div class="form-group">
<label for="price" class="col-sm-2 control-label">Price:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="price" id="price" value="<?php echo (isset($_POST['price'])) ? $_POST['price'] : ''; ?>" placeholder="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</div>
</div>
<?php
if(isset($total)){
echo '<div class="alert alert-success"> You will make '.$total.'</div>';
}
?>
</form>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment