Solved

reduce POST value by 75

Posted on 2008-09-30
6
180 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 110

Expert Comment

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

Accepted Solution

by:
Ray Paseur earned 500 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Closing Comment

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 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