PHP Developers Network

First time using PHP
Page 1 of 1

Author:  Lucious [ Sat Mar 03, 2018 12:22 pm ]
Post subject:  First time using PHP

I need to make a simple form that a user enters an amount and the forum multiplies the amount by 300


user enters the amount 23,000
they click submit and it gives them the answer 6,900,000

Any help or direction with this would be a great help

Author:  Christopher [ Wed Mar 07, 2018 7:57 pm ]
Post subject:  Re: First time using PHP

You can use PHP for that. The value would be from an HTML <input> field and PHP would receive it in the $_POST array.

File: form.php
Syntax: [ Download ] [ Hide ]
if (isset($_POST['number']) {
    $number = filter_input(INPUT_POST, 'number', FILTER_SANITIZE_NUMBER_INT);
    $total = $number * 300;
    echo "$number x 300 = $total";
} else {
<form action="form.php" method="post>
Number:<input type="text" name="number" value="" size="10">
<input type="submit" name="submit" value="Multiply">

You could also do this in Javascript in the browser. Add an onSubmit event to the form and then get the value of the input field.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group