0
當我放入圖像上傳代碼時,出現此錯誤。沒有它,一切都有效。我已經重寫了很多次,並且搜索了很多次,但是我仍然得到:注意:未定義的索引:第12行的C:\ wamp \ www \ HW2_Submissions \ movieSub.php中的file_img當我將兩者分離到那裏擁有圖像時,和creatmovie作品他們自己的工作很好。我給你的片段是HTML的主體區域,有一個菜單,頭部,連接和頁腳php文件分離出來,並且連接包含數據庫信息。請幫助謝謝你。未識別的索引錯誤PHP
<?php
if (isset($_POST['add'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$movie = $_POST['movie'];
$director = $_POST['director'];
$lead = $_POST['lead'];
$textArea = $_POST['textArea'];
$filetmp = $_FILES["file_img"]["tmp_name"];
$filename = $_FILES["file_img"]["name"];
$filetype = $_FILES["file_img"]["type"];
$filepath = "images/".$filename;
$query = "INSERT INTO createmovie (movieID, userName, email, movieName, directorsName, lead, Info) VALUES
(NULL,'$name', '$email', '$movie', '$director', '$lead','$textArea'); INSERT INTO images (imageID, img_name, img_path, img_type) VALUES (NULL, '$filename','$filetype','$filepath')";
mysqli_multi_query($conn, $query);
// $result = $conn->query($query);
// if (!$result) die($conn->error);
if (headers_sent()) {
die("Redirect failed. Please click on this link: <a href='movies-list.php'>Movie List</a>");
}else{
exit(header("Location: movies-lists.php"));
}
?>
<div class="clearfix colelem" id="u711-4"><!-- content -->
<p>Welcome Please Submit Movie</p>
</div>
<form action="movie-add.php" method="post" style="padding-top: 220px">
<div class="form-group" >
<label for="InputName1">Your Name</label>
<input type="name" name="name" class="form-control" id="InputName1" aria-describedby="nameHelp" placeholder="Enter Name">
<small id="nameHelp" class="form-text text-muted">We'll never share your information with anyone else.</small>
</div>
<div class="form-group">
<label for="Inputemail1">Email</label>
<input type="email" name="email" class="form-control" id="Inputemail1" placeholder="Email">
</div>
<div class="form-group" >
<label for="InputMovie1">Movie Name</label>
<input type="text" name="movie" class="form-control" id="InputMovie1" aria-describedby="movieHelp" placeholder="Movie Name">
</div>
<div class="form-group" >
<label for="InputDirector1">Directors Name</label>
<input type="text" name="director" class="form-control" id="InputDirector1" aria-describedby="directorHelp" placeholder="Director Name">
</div>
<div class="form-group" >
<label for="InputLead1">Lead Actor/Actress</label>
<input type="text" name="lead" class="form-control" id="InputLead1" aria-describedby="LeadHelp" placeholder="Lead Name">
</div>
<div class="form-group">
<label for="Textarea">More Information</label>
<textarea class="form-control" id="Textarea" name="textArea" rows="3"></textarea>
</div>
<div class="form-group">
<input type="file" name="file_img" />
</div>
<button type="submit" name="add" class="btn btn-primary" >Submit</button>
</form>
@Daominhat感謝我很感激我發誓,我嘗試過這一點。但無論現在它是否奏效。謝謝 – Rico