PHP Developers Network
http://forums.devnetwork.net/

First time using PHP
http://forums.devnetwork.net/viewtopic.php?f=1&t=146584
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

example

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 ]
<?php
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">
</form>
<?php
}
?>


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
http://www.phpbb.com/