|
Posted by Newbie Supreme on 09/28/40 11:42
Thank you very much, Norm, appreciated.
Are these variables maintained from page to page? I mean, the $_Request
goes on the second page, while the form fields are on the first, correct?
Can I continue advancing pages with the same variable names? Or do I need
to declare them on each page? My intent is to use the chfeedback php script
to email the form field data and results to an email address.
In terms of syntax, these { } are always supposed to enclose the seting of a
variable value? Or am I oversimplifying their purpose?
Thanks again, that was very helpful.
"Norman Peelman" <npeelman@cfl.rr.com> wrote in message
news:7bTRf.77991$Fw6.15454@tornado.tampabay.rr.com...
> "Newbie Supreme" <newbiesupreme@yahoo.com> wrote in message
> news:qbidneQcLK71OorZRVn-jw@comcast.com...
>> I'm practicing using form fields to add, subtract, multiply, etc., and
> send
>> that data to pages as well as to email scripts. It seems I'm decent with
>> basic calculations, but when it comes to things like adding an amount if
>> a
>> certain checkbox is clicked, or using if/thens, I'm totally at a loss.
>>
>> Can anyone show me the php used to do the following:
>>
>> Page 1 has Field1, Field2, and Field3, all textboxes. It also has Check1
>> and Check2 These are checkboxes.
>>
>> How can page two show the result of:
>>
>> ((Field1 + Field2) x Field3) + 300 if Check1 is checked (0 if not) + 100
> if
>> Check2 is checked (0 if not)
>>
>> For example, if on the 1st page the user puts 10 in Field1, 5 in Field2,
> and
>> 4 in Field3, then checks Check2, the result is 160 (10 + 5, multiplied by
> 4,
>> then adding 100).
>>
>> Any help is appreciated, or if you know of a website that shows
> caluclations
>> with form fields in PHP, going from basic to complex, I would love to
>> find
>> it. I found one for ASP that was very helpful, it shows the code and had
>> example pages for progressively more complicated calculations, with very
>> small increments of difficulty, so you could learn very quickly.
>>
>> Thanks for reading.
>>
>>
>
> minus any error checking:
>
> ---
>
> if (isset($_REQUEST['Check1']))
> {
> $tmp = 300;
> }
> elseif(isset($_REQUEST['Check2']))
> {
> $tmp = 100;
> }
> else
> {
> $tmp = 0;
> }
>
> /* you can also do this shortform once you get the hang of it
> $tmp = isset($_REQUEST['Check1']) ? 300 : isset($_REQUEST['Check2']) ? 300
> :
> 0;
> */
>
> $result = (($_REQUEST['Field1'] + $_REQUEST['Field2']) *
> $_REQUEST['Field3']) + $tmp;
>
> echo $result;
> ---
>
>
> Norm
>
>
Navigation:
[Reply to this message]
|