Solved

reduce POST value by 75

Posted on 2008-09-30
6
178 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
  • 3
  • 3
6 Comments
 
LVL 108

Expert Comment

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

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Closing Comment

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
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 …

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now