Today I will tell you how you can craete Acceleration Calculator Using PHP? First of all, you create an html form, add text field and 1 button. I will tell you explain step by step how you can craete Acceleration Calculator Using PHP For this you can see in the example mentioned below.
- Create HTML code.
- Creat php code of Acceleration Calculator.
- Mix html/PHP Code in One File (acceleration-calculator.php).
Create HTML code.
To get Acceleration through calcutor, you have to first create the form in an html. So first of all you create the form in html. In the form, you have to take an input type of text. And then a submit button. You are given the code of the form with the example below. With the help of which you can understand.
<!DOCTYPE html> <html> <head> <title>Accelarration Calculator</title> </head> <body> <div class="controls"> <div class="row"> <form method="post"> <div class="col-md-6"> <div class="form-group"> <label for="form_name">Initial Velocity: *</label> <input type="number" name="i" class="form-control"></div> </div> <div class="col-md-6"> <div class="form-group"> <label for="form_lastname">Final Velocity: *</label> <input type="number" name="f" class="form-control"></div> </div> <div class="col-md-6"> <div class="form-group"> <label for="form_lastname">Time: *</label> <input type="number" name="t" class="form-control"></div> </div> </div> <div class="row"> <div class="col-md-12"> <input type="submit" name="submit" value="Acceleration Check Value"></div> </div> </form> </div> </body> </html>
Creat php code of Acceleration Value Get.
Now you have been told about the most important code below. You can get acceleration value with the help of this code. Now you can understand this code by looking below.
<?php if (isset($_POST['submit'])) { $i=$_POST['i']; $f=$_POST['f']; $t=$_POST['t']; $s=$f-$i; echo 'Acceleration: *'.$s/$t.'m/s2'; } ?>
Mix html/PHP Code in One File (acceleration-calculator.php).
Now you have to add this code to a single file (acceleration-calculator.php). The example of which is given below. You can copy the code of this file to your php You can use it by adding it to the file.
acceleration-calculator.php
<!DOCTYPE html> <html> <head> <title>Accelarration Calculator</title> </head> <body> <div class="controls"> <div class="row"> <form method="post"> <div class="col-md-6"> <div class="form-group"> <label for="form_name">Initial Velocity: *</label> <input type="number" name="i" class="form-control"></div> </div> <div class="col-md-6"> <div class="form-group"> <label for="form_lastname">Final Velocity: *</label> <input type="number" name="f" class="form-control"></div> </div> <div class="col-md-6"> <div class="form-group"> <label for="form_lastname">Time: *</label> <input type="number" name="t" class="form-control"></div> </div> </div> <div class="row"> <div class="col-md-12"> <input type="submit" name="submit" value="Acceleration Check Value"></div> </div> </form> </div> </body> </html> <?php if (isset($_POST['submit'])) { $i=$_POST['i']; $f=$_POST['f']; $t=$_POST['t']; $s=$f-$i; echo 'Acceleration: *'.$s/$t.'m/s2'; } ?>