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

Posted on 2007-08-07
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
Do not display anything

How can I do this?

Thanks so much,
Question by:lshane
    LVL 142

    Accepted Solution

    if (@$_POST["FORM FIELD NAME"] == "Y")
      Display a paragraph of text

    Author Comment

    Thanks, angellll.  I appreciate that!

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

    Thanks again,

    Author Comment

    One other quick question, please:

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

    Expert Comment

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

    Author Comment

    Thanks SO much!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    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 …

    794 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

    17 Experts available now in Live!

    Get 1:1 Help Now