Help with automatic calculation after entering a field in a php form

I have the below code that a user enter information in a form. Then it take the values and start a topic in a designated forum with the users answers. You can see what it looks like from the screenshots.

Anyway, I want to add a new line in the posted topic that calculated how much SRF Cash it will cost the user depending on the price field that they entered.

User enter price in a form
Number1 = price Round to the nearest .50
So $2.27 would be $2.50
S0 $2.64 would be $3.00
Total = (Number1 divided by $.50) * 100 i.e. Total = (roundToNearest answer/ .50) * 100

I want to pass the total to the forum topic that says (This book will cost you (total) SRF Cash)!

I found a function that calculate to the nearest .50 but I don’t know if it’s correct. But here it is below. Just wan’t to know what to add to application.php code to calculate the total and then pass it to the forum topic?

roundToNearest

function roundToNearest($number,$nearest=50)
  {
      $number = round($number);
  
      if($nearest>$number || $nearest <= 0)
          return $number;
  
      $x = ($number%$nearest);
      
      return ($x<($nearest/2))?$number-$x:$number+($nearest-$x);
  }

Application.php

<?php
/**
* @package application.php
* @copyright (c) JimA http://beta-garden.com 2009
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/application');

// You need to login before being able to send out an application
if ($user->data['user_id'] == ANONYMOUS)
{
    login_box('', $user->lang['LOGIN_APPLICATION_FORM']);
}

include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

// Let's set the configuration, this is the ID of the forum where the post goes to
$forumid_send = 32;

$submit = (isset($_POST['submit'])) ? true : false;

	if ($submit)
	{

// Setting the variables we need to submit the post to the forum where all the applications come in
$apply_subject  = sprintf($user->lang['APPLICATION_SUBJECT'], $user->data['username']);
$apply_post     = sprintf($user->lang['APPLICATION_MESSAGE'], $user->data['username'], request_var('postion', '', true), utf8_normalize_nfc(request_var('title', '', true)), utf8_normalize_nfc(request_var('author', '', true)), utf8_normalize_nfc(request_var('price', '', true)), utf8_normalize_nfc(request_var('bookstore', '', true)), utf8_normalize_nfc(request_var('booklink', '', true)), utf8_normalize_nfc(request_var('why', '', true)));

// variables to hold the parameters for submit_post
$poll = $uid = $bitfield = $options = ''; 

generate_text_for_storage($apply_post, $uid, $bitfield, $options, true, true, true, true, true, true, true);

$data = array( 
	'forum_id'		=> $forumid_send,
	'icon_id'		=> false,

	'enable_bbcode'		=> true,
	'enable_smilies'	=> true,
	'enable_urls'		=> true,
	'enable_sig'		=> true,

	'message'		=> $apply_post,
	'message_md5'	=> md5($apply_post),
				
	'bbcode_bitfield'	=> $bitfield,
	'bbcode_uid'		=> $uid,

	'post_edit_locked'	=> 0,
	'topic_title'		=> $apply_subject,
	'notify_set'		=> false,
	'notify'			=> false,
	'post_time' 		=> 0,
	'forum_name'		=> '',
	'enable_indexing'	=> true,
);

// Sending the post to the forum set in configuration above
submit_post('post', $apply_subject, '', POST_NORMAL, $poll, $data);

$message = $user->lang['APPLICATION_SEND'];
$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
trigger_error($message);
}

$template->assign_block_vars('navlinks', array(
  'FORUM_NAME'    => $user->lang['REDEEM'],
  'U_VIEW_FORUM'  => append_sid("{$phpbb_root_path}viewforum.php?f=31"),
));

$template->assign_block_vars('navlinks', array(
  'FORUM_NAME'    => $user->lang['APPLICATION'],
  'U_VIEW_FORUM'  => append_sid("{$phpbb_root_path}application.$phpEx"),
));

page_header($user->lang['APPLICATION_PAGETITLE']);

$template->assign_vars(array(
	'PROCESS_APPFORM'	=> append_sid("{$phpbb_root_path}application.$phpEx"),
	));
	
$template->set_filenames(array(
    'body' => 'appform_body.html',
));

page_footer();

?>

My forum is located here: Sony Reader Forum
You have to be a member to use the form or even access the Redeem forum. That’s why I included screenshots. If account access is needed, I’ll be happy to PM a test account. Thanks

Round to the nearest .50 =

Round(<Number> * 2) / 2

0.25 * 2 = .50 rounded = 1 / 2 = 0.50
0.22 * 2 = .44 rounded = 0 / 2 = 0.00
1.22 * 2 = 2.44 rounded = 2 / 2 = 1

etc.

Basic manipulation of the ROUND() function going to a whole number.

It’s not the math I need but how to pull the field from the entry. I need the code. Thanks


	'topic_title'		=> $apply_subject,

The part of the $apply_post line that appears to be related is: utf8_normalize_nfc(request_var(‘price’, ‘’, true)).

What the request_var function does is beyond the scope of this page, but i’m assuming what it does is get the value of $_POST[‘price’]. So… $number = utf_normalize_nfc(request_var(‘price’,‘’,true)); ? I’m guessing here without seeing those functions.