How do I make this Form, in this PHP file, accessible via an html page?

How do I make the Form in this PHP file accessible via an html page, so that it still works successfully with this PHP file? Here’s the php file code:

<?php
session_start();
require_once 'phps3integration_lib.php';
$message = "";
if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip", "flv", "mp4");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] < 32428800) && in_array($extension, $allowed_ext)) {
        if ($_FILES["file"]["error"] > 0) {
            //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "<br>";//Enable this to see actual error
            $message.="There is some error in upload. Please try after some time.";
        } else {
            $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true);
            if ($uploaded_file != FALSE) {
                $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
                $form_data = array(
                    'file' => $uploaded_file,
                    'user_name' => $user_name,
                    'type' => 'file'
                );
                mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
                $message.= "File successfully uploaded in S3 Bucket.";
            } else {
                $message.="There is some error in upload. Please try after some time.";
            }
        }
    } else {
        $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip file of maximum size 30 MB.";
    }
}
?>

<?php
require_once 'header.php';
?>
<fieldset>
    <legend>PHP AWS S3 integration library Demo1</legend>
    Description: In this demo a file is being upload to an S3 bucket using "PHP AWS S3 integration library". After upload you can check the uploaded file in below table.
    If you require some manipulation before uploading file to S3 then check <a href="upload_file_manually.php">Demo2</a> <br />
    <br />

    <form action="" method="post" enctype="multipart/form-data">

        <div class="control-group">
            <label for="file" class="control-label">Choose a file to upload: <span style="color:red">*</span></label>
            <div class='controls'>
                <input id="file" type="file" name="file" />
                <?php //echo form_error('file');   ?> </div>
        </div>
        <div class="control-group">
            <label for="user_name" class="control-label">Your name:</label>
            <div class='controls'>
                <input id="user_name" type="text" name="user_name" maxlength="255" value=""  />
                <?php //echo form_error('user_name');   ?> </div>
        </div>
        <div class="control-group">
            <label></label>
            <div class='controls'>
                <input type="submit" name="submit" value="Submit" class="btn">
            </div>
        </div>
    </form>
</fieldset>
<?php
if ($message != "" || @$_SESSION['message'] != "") {
    ?>
    <div class="alert alert-success">
        <?php echo $message; ?>     
        <?php
        echo @$_SESSION['message'];
        @$_SESSION['message'] = '';
        ?>
    </div>
    <?php
}
?>
<div>
    <table  class="table table-hover">
        <caption>
            <strong>Last 10 user uploaded files</strong>
        </caption>
        <?php
        $files_result = mysql_query("SELECT * from `phps3files` WHERE type LIKE 'file' ORDER by id DESC LIMIT 10");
        $i = 1;
        while ($file = mysql_fetch_object($files_result)) {
            ?>
            <tr>
                <td><?php echo $i++; ?></td>
                <td><a href="<?php echo site_url_s3("uploads/" . $file->file); ?>" target="_blank">View/Download</a> </td>
                <td><a href="<?php echo site_url("delete_file.php?id=" . $file->id); ?>">Delete file from S3</a></td>
                <td><?php echo "Uploaded by: " . $file->user_name; ?></td>
            </tr>
            <?php
        }
        if ($i == 1) {
            ?>
            <tr>
                <td colspan="2"> No files uploaded yet</td>
            </tr>
            <?php
        }
        ?>
    </table>
</div>
<h4>Source Code Part of Demo</h4>
<pre class="prettyprint lang-php linenums">
<?php
session_start();
require_once 'phps3integration_lib.php';
$message = "";
if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] < 32428800) && in_array($extension, $allowed_ext)) {
        if ($_FILES["file"]["error"] > 0) {
            //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "<br>";//Enable this to see actual error
            $message.="There is some error in upload. Please try after some time.";
        } else {
            $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true);
            if ($uploaded_file != FALSE) {
                $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
                $form_data = array(
                    'file' => $uploaded_file,
                    'user_name' => $user_name,
                    'type' => 'file'
                );
                mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
                $message.= "File successfully uploaded in S3 Bucket.";
            } else {
                $message.="There is some error in upload. Please try after some time.";
            }
        }
    } else {
        $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip file of maximum size 30 MB.";
    }
}
?>
</pre>
<?php require_once 'footer.php'; ?>

Any help will be greatly appreciated.

The HTML in the file will still be parsed as HTML (and the PHP as PHP since it is enclosed in php tags). Are you trying to separate the HTML into a separate .html file? If so, you can place the HTML in someFile.html and the PHP in someFile.php, and alter the <form> tag’s ‘action’ element in the .html file to target someFile.php.

Thanks for your reply.
Yes, I’d like to separate the HTML into a separate .html file.
How do I "alter the <form> tag’s ‘action’ element in the .html file to target the exiting upload_file.php?
I look forward to any additional help.

In the action=“” in the <form> tag, you can specify some_file.php i.e. <form action=“some_file.php” method=“POST” …

Then you can put the HTML of the form into a .html file and keep the PHP in the PHP file.

Thanks so much for that help. Much appreciated.
I now have an html file and php file (as shown below),
but I need help to tweak it, please.
I’ve attached an image also, of what it looks like.

It uploads successfully currently, but there is no “File successfully uploaded” or “invalid file” messages showing after “Submit”.

Can you help me with that, please?

<html>
<head>Upload
</head>
<body>
<?php require_once 'header.php'; ?>

<fieldset>
<form action="upload_file.php" method="post" enctype="multipart/form-data">

<div class="control-group">
<label for="file" class="control-label">Choose a file to upload: <span style="color:red">*</span></label>
<div class='controls'>
<input id="file" type="file" name="file" />
<?php //echo form_error('file');   ?> </div>
</div>

<div class="control-group">
<label for="user_name" class="control-label">Your name:</label>
<div class='controls'>
<input id="user_name" type="text" name="user_name" maxlength="255" value=""  />

<?php //echo form_error('user_name');   ?> </div>
</div>

<div class="control-group">
<label></label>
<div class='controls'>
<input type="submit" name="submit" value="Submit" class="btn">
</div>
</div>
</form>
</fieldset>

<?php echo "<div class=\\"alert alert-success\\">{$message}</div>"; ?>
<div>
<table  class="table table-hover">

<?php echo $file_list_HTML; ?>
</table>
</div>
<pre class="prettyprint lang-php linenums">

</pre>
<?php require_once 'footer.php'; ?>

</body>
</html>

&lt;?php
session_start();
require_once 'phps3integration_lib.php';
$message = "";
if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip", "flv", "mp4", "mov");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] &lt; 32428800) && in_array($extension, $allowed_ext)) {
        if ($_FILES["file"]["error"] &gt; 0) {
            //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "&lt;br&gt;";//Enable this to see actual error
            $message.="There is some error in upload. Please try after some time.";
        } else {
            $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true);
            if ($uploaded_file != FALSE) {
                $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
                $form_data = array(
                    'file' =&gt; $uploaded_file,
                    'user_name' =&gt; $user_name,
                    'type' =&gt; 'file'
                );
                mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
                $message.= "File successfully uploaded.";
            } else {
                $message.="There is some error in upload. Please try after some time.";
            }
        }
    } else {
        $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip/flv/mp4/mov file of maximum size 30 MB.";
    }
}
?&gt;