Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP:  Syntax for IF THEN statement to display a form field

Posted on 2007-08-07
5
Medium Priority
?
282 Views
Last Modified: 2013-11-05
Hello.  I know very little about PHP.  I primarily use ASP.  I am, however, having to alter a portion of code on a PHP page.

I need to have an IF THEN statement to display a form field ("Lyme").

The conditional statement is on an "Order Confirmation" page.  There is a form on the "Order" page named "Lyme".  On the "Order Confirmation" page, I would like to basically say:

IF {formfieldfrom ORDER page} is equal to "Y" THEN
Display a paragraph of text
ELSE
Do not display anything


How can I do this?

Thanks so much,
Shane
0
Comment
Question by:lshane
  • 3
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19649240
if (@$_POST["FORM FIELD NAME"] == "Y")
{
  Display a paragraph of text
}
0
 

Author Comment

by:lshane
ID: 19649575
Thanks, angellll.  I appreciate that!

I'll give it a try shortly, but it seems very straightforward.


Thanks again,
Shane
0
 

Author Comment

by:lshane
ID: 19649586
One other quick question, please:

Do I need to place delimiters around that code?  (i.e. <?......?>    OR   <? PHP..... ?>    etc.)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19649796
yes, as that is PHP code.
you should prefer the <?PHP ?> version, as the <? shorttags version is not supported (configured) on all web hostings...
0
 

Author Comment

by:lshane
ID: 19650667
Thanks SO much!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 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