Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Embedding Static Content in PHP if Statements

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29333
    spate1y
    Member

    Hi there,

    I got a quick question about the correct way incorporate HTML code into PHP if statements.

    If I have the following code:

    Code:
    if(condition) {
    //WANT MY DIVS, CONTENT, AND FORM HERE
    }
    else {
    die (“You need to be logged in to view this page.”);
    }

    How would I (or how do professionals) insert their divs, content, and forms? Or am I even using the correct method? The page that contains this code is a member only type page that users must be logged in to view.

    I am thinking that if I do some type of embedding of an external file then a hacker would find the external file and go directly to that file on the server.

    Thanks so much! BTW… I am learning to develop my own app with PHP so I’m mostly a newbie :)

    #77679
    vincent
    Member

    I’m kinda new too…but, I do it by either closing off ?> php or echoing the html.

    Code:

    or

    Code:

    “;
    }
    ?>

    For big things like forms, I would close off ?> php, add the html, then restart php.

    #77692
    spate1y
    Member

    I had seen that first solution of ending the tag on the php.net website. I tried that but it didn’t work for me.

    I am wondering how professional/major websites do this.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.