?
Solved

reduce POST value by 75

Posted on 2008-09-30
6
Medium Priority
?
182 Views
Last Modified: 2012-05-05
Hello,

In the below code I am checking if a post value exists, if it does I want to reduce that amount by 75.00, is teh code below correct?

Thank you.
if (isset($_POST['amount']))
	{
	$_POST['amount']= ($_POST['amount']-'75.00');
	}

Open in new window

0
Comment
Question by:vrmetro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22606360
You should remove the quotes from '75.00'
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 22606407
I might do something like this.  What edits you would do would depend on what final values are acceptable for your application.
if (isset($_POST['amount']))
{
        $amount	= trim(ereg_replace("[^0-9\.\-]", "", $_POST['amount']));
        $amount = $amount - 75.00;
        $_POST['amount']= $amount; // OR JUST USE $AMOUNT
}

Open in new window

0
 

Author Comment

by:vrmetro
ID: 22606687
What does this part do?

ereg_replace("[^0-9\.\-]",
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 

Author Closing Comment

by:vrmetro
ID: 31501584
what does ereg_replace("[^0-9\.\-]",  do?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22606978
Hi,vrmetro:Thanks for the points!  That ereg statement discards everything except the numerals, the decimal point and the minus sign.  You would not get a meaningful answer if $_POST had "$79.00" in the field - unless you made some edits to control for the kind of data that work with arithmetic. ~Ray
0
 

Author Comment

by:vrmetro
ID: 22607536
thanks Ray, much appreciated.
0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question