944,117 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 686
  • PHP RSS
Nov 4th, 2009
0

using variable substitutions in conditional statements

Expand Post »
Hi,

I don't know if I have just been working too much or have gone brain dead (or both), but the solution to this eludes me.

I am using PHORM ( a PHP form processor) which uses variable substitution to allow you to quickly create user interaction pages etc. What I am doing here is creating an application over two pages. On the first page, we are collecting membership application info, including the type of membership and how they would like to pay for their membership (PayPal or invoicing). How PHORM works is that when you submit the form, the output is sent to the phorm.php script which does certain things, depending on the config for that form. In this case, it sends an email to the site owner, a confirmation email to the user and then redirects them to an acknowledgment page (page 2 of our little app). What I want is for all of this to happen as stated but, on the acknowledgment page, based on on the type of membership and payment preferences, build a Paypal button to submit the appropriate payment or, if they are being billed, simply indicate that they will receive an invoice via mail or email, as the case may be.

PHORM uses variables in the form of {{field name from form}}. So in our case here, the values that I need are available on the acknowledgment page as {{howPay}} and {{appType}}. However, I am trying to use variations on the following in order to show or not show certain info on the page:

PHP Syntax (Toggle Plain Text)
  1. <?php if ({{howpay}} == paypal) { ?>
or
PHP Syntax (Toggle Plain Text)
  1. <?php if ($_POST['howpay'] == paypal) { ?>
but with no success. In the first case, when you look at the code, you just see
PHP Syntax (Toggle Plain Text)
  1. <?php if (paypal == paypal) { ?>
which does not seem to work. I even tried:
PHP Syntax (Toggle Plain Text)
  1. <? $pay = {{howpay}} ?>
but that does not work either.

I would appreciate a fresh pair of eyes on this and a fresh brain.

Thanks

Dave
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 4th, 2009
-1
Re: using variable substitutions in conditional statements
Do you need to enclose paypal within quotes?
This is a templating engine I take it.

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. if({{howpay}} == "paypal"){
  3. ...
  4. }
  5. ?>
Last edited by ardav; Nov 4th, 2009 at 4:11 pm.
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 955
Disgraced Poster
ardav is offline Offline
6,728 posts
since Oct 2006
Nov 4th, 2009
0
Re: using variable substitutions in conditional statements
Click to Expand / Collapse  Quote originally posted by ardav ...
Do you need to enclose paypal within quotes?
This is a templating engine I take it.

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. if({{howpay}} == "paypal"){
  3. ...
  4. }
  5. ?>
I have tried using quotes but that did not work either.

Phorm is not really a templating engine. It is simply a big PHP script that handles various types of form submits. See http://www.php-form.net

Dave
Reputation Points: 10
Solved Threads: 1
Junior Poster
filch is offline Offline
132 posts
since Nov 2008
Nov 4th, 2009
0
Re: using variable substitutions in conditional statements
Click to Expand / Collapse  Quote originally posted by filch ...
I have tried using quotes but that did not work either.

Phorm is not really a templating engine. It is simply a big PHP script that handles various types of form submits. See http://www.php-form.net

Dave
Can't see any documentation on the site, and I ain't gonna download the app.

How about:


PHP Syntax (Toggle Plain Text)
  1. if($_POST[{{howpay}}] == "paypal") ...


If so, I fail to see the use of the variable name swapping.

Can you do a print_r($_POST)?

That should give you the name of all the form posted variable keys and values.

Hmm, just thought, I expect you are passing variables via POST and not GET.
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 955
Disgraced Poster
ardav is offline Offline
6,728 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC