How to include PHP file in HTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • los799
    New Member
    • Feb 2013
    • 4

    How to include PHP file in HTML

    I'm trying to make a HTML page read a external PHP file with a variable:

    File:

    Code:
    <?php
    	$email = "test@test.com"
    ?>
    HTML:

    Code:
    <html>
    	<head>
    	</head>
    	<body>
    		<?php include ( "File1.php" ); ?>
    		The e-mail in the file is: <?php echo $_POST [ 'email' ] ?>
    	</body>
    </html>
    It results:

    "The e-mail in the file is:"

    Nothings more, can anyone help me in this?

    @Edit

    Sorry for the wrong area, can any moderator move it?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    moved to PHP forum.

    you have a misconception is about $_POST and include.

    in the $_POST array are variables that are passed from the requesting user agent via the HTTP POST method.

    include simply imports a file into the current script.

    if you resolve the include in your previous code, it would look like
    Code:
    <html>
        <head>
        </head>
        <body>
            <?php
        $email = "test@test.com"; 
            ?>
            The e-mail in the file is: <?php echo $_POST [ 'email' ] ?>
        </body>
    </html>
    I think that should clear up things a bit.

    Comment

    • los799
      New Member
      • Feb 2013
      • 4

      #3
      Ok, but if the var email is in a external php file, what should I do?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        external like on a different server?

        Comment

        Working...