从admin.php使用时提交不起作用

时间:2014-10-31 20:04:28

标签: php html forms include

我有一个admin.php页面,其中包含一个名为programs.php的包含。这包括在/includes/programs_form.php中生成一个文件夹。 programs_form.php使用名为image_programs.php的动作,该动作也存在于includes文件夹中。表单中的提交按钮直接从programs_form.php调用,但从admin.php调用时不起作用。我猜它与我如何调用image_programs.php有关,但我不确定...谢谢

HTML:

        <h3 style="text-align:center">Add A Program</h3>

    <div  class="wrapperadmin">

        <p style="text-align:center">

            <table width="400" border="2" cellspacing="1" cellpadding="2">           
                <form id="comment_form" name="Image" enctype="multipart/form-data" action="image_programs.php" method="POST">

                    <tr>
                        <td width="100">Program Name</td>
                    </tr>
                    <tr>
                        <td><input class="commentarea" name="program_name" type="text" id="program_name" placeholder="Program Name."></td>
                    </tr>

                    <tr>
                        <td width="100">Program Description</td>
                    </tr>
                    <tr>
                        <td><textarea class="commentarea" name="program_description" type="text" id="program_description" rows="10" style=" overflow:hidden; height:auto" placeholder="Your Program Descrition Here."  ></textarea></td>
                    </tr>
         <tr>
                        <td>
                        <input type="File" name="Photo" size="2000000" accept="image/gif, image/jpeg, image/x-ms-bmp, image/x-png" size="26"></td>
                    </tr>

                     <tr>
                        <td>
                        <INPUT type="submit" class="button" name="Submit" value="Submit" size="26">
                        </td>
                    </tr>      


                </form>

            </table>

        </p>

    </div>

PHP:

    <?PHP
    error_reporting(E_ALL); ini_set('display_errors', 1);
    $hostname = "localhost:3306"; 
    $db_user = "root"; 
    $db_password = "admin"; 
    $database = "smlc"; 
    $db_table = "program";
    $db = mysqli_connect($hostname, $db_user, $db_password);
          mysqli_select_db($db, $database);

    $uploadDir=dirname(__FILE__)."/images/uploaded/programs/";

    if(isset($_POST['Submit']))
    {
    $program_name = $_POST['program_name'];
    $program_description = $_POST['program_description'];
    $fileName = $_FILES['Photo']['name'];
    $tmpName = $_FILES['Photo']['tmp_name'];
    $fileSize = $_FILES['Photo']['size'];
    $fileType = $_FILES['Photo']['type'];
    $filePath = $uploadDir . $fileName;
    $result = move_uploaded_file($tmpName,$filePath);
    if (!$result) {
    echo "Error uploading file";
    exit;
    }
    if(!get_magic_quotes_gpc())
    {
    $fileName = addslashes($fileName);
    $filePath = addslashes($filePath);
    }

    $sql_program = "INSERT INTO program (program_name, program_description,filepath) 
    VALUES ('$program_name', '$program_description','$filePath')";



    $retval = mysqli_query($db, $sql_program);
    if(! $retval )
    {
      die('Could not update data: ');
    }
    echo "<script type='text/javascript'>alert('Update Successful!');</script>";



    }
    else
    {

    }
    ?>

1 个答案:

答案 0 :(得分:0)

事实证明我的标签位于我的标签内,阻止它正确读取动作。我显然需要更多的咖啡