PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Sep 18, 2018 8:24 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: First time using PHP
PostPosted: Sat Mar 03, 2018 12:22 pm 
Offline
Forum Newbie

Joined: Sat Mar 03, 2018 12:18 pm
Posts: 1
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


Top
 Profile  
 
 Post subject: Re: First time using PHP
PostPosted: Wed Mar 07, 2018 7:57 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13575
Location: New York, NY, US
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.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group