如何在HTML代码中包括PHP文件



我在htdocs下有一个文件夹"尝试",我将PHP文件连接到HTML,但不包括PHP文件。我的代码有问题吗?

<?php
include 'init.inc.php';
?>

HTML和PHP文件在"尝试"文件夹中。原谅我,我只是一个新手!

index.html的代码:

<?php
include('init.inc.php');
if(isset($POST['name'], $_FILES['files'])){
    mail_file('grace.cuteens@gmail.com', 'grace.cuteens@gmail.com', 'A File 
Upload', '', $_FILES['file']);
}
?>

<html>
    <head> BACK UP AND SEND 
    <title> BACK UP DATABASE AND SEND TO GMAIL PAGE </title>
    </head>
    <body>
        <br>
        <br>
        <img src="gslc.jpg" alt="GSLC" style="width:304px;height:228px;">
        <div>
            <form action = "" method = "post" enctype = "multupart/form-
data">
                <p>
                    <label for="name">Name</label>
                    <input type="text" name="name" id="name" />
                </p>
                <p>
                    <label for="file">File</label>
                    <input type="file" name="file" id="file" />
                </p>
                <p>
                    <input type="submit" value="Email File" />
                </p>
            </form>
         </div>     
    </body>
</html>

init.inc.php的代码:

<?php
$path = dirname(_FILE_);
include("{$path}/mail.inc.php");
?>

mail.inc.php的代码:

<?php
function mail_file($to, $from, $subject, $body, $file){
    $boundary = md5(rand());
    $headers = array(
        'MIME-Version: 1.0',
        "Content-Type: multipart/mixed; boundary="{boundary}"",
        "From: ($from)"
        );
        $message = array(
            "--{$boundary}",
            "Content-Type: text/plain",
            "Content-Transfer-Encoding: 7bit"
            '',
            chunk_split($body),
            "--($boundary)"
            "Content-Type: {$file['type']}; name='{$file['name']}"",
            "Content-Disposition: attachment; filename='{$file['name']}"",
            "Content-Transfer-Encoding-base64",
            '',
chunk_split(base64_encode(file_get_contents($file['tmp_name']))),
            "--($boundary)--"
         );
        mail ($to, $subject, implode("rn", $message), implode("rn", 
$headers));
}
?>

我的问题是包括PHP文件(包括PHP文件(似乎不正确的代码。所有文件都位于HTDOC下的"尝试"文件夹中,我已经运行Apache

最新更新