Easy question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chocogrum
Forum Newbie
Posts: 1
Joined: Thu Apr 07, 2005 10:00 am

Easy question

Post by chocogrum »

Hi! I know this is probably an easy question for many of you but I am new to php and was hoping you can help me. I basically have an online form and have a field where the user enters the cost of the product they wish to buy. There is also a 'Discount' check box. If this is checked, the user gets their product at half price. If the check box is checked, when the submit button is pressed I want the discounted cost to be recorded in my database, not the full cost. I was trying to use an equation like this:

Code: Select all

$subtotal = $HTTP_POST_VARSї'cost'] - $HTTP_POST_VARSї'cost'] * $HTTP_POST_VARSї'discount'] * 0.5
Then submit it using the line:

Code: Select all

GetSQLValueString($total, &quote;double&quote;)
The information is stored in the database fine if I just submit the cost as is entered but when I try to use the code above, the page won't even load when I try to access it. I have looked at many online sources and cannot seem to find an answer that wouldn't require ordering and reading books.

Thanks in advance for any help!
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

first you calculate $subtotal..... and then use (uninitialised) $total?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you come back chocogrum, please have a read through the "Posting Code Guidelines" linked to ... everywhere.. (posting pages, my signature, in many many many many posts)
Post Reply