我一直想弄清楚为什么我的表单不会提交。单击提交按钮时没有任何反应。经过一整晚的尝试,重写,搜索......我只是不知道我的代码有什么问题。谁可以帮助我?非常感谢..
<form method="POST" id="newdiscussion form" enctype="multipart/form-data">
<div class="input-group">
<span class="input-group-addon">Select a category</span>
<select class="form-control" name="category">
<option value="Experiences">Flying experiences</option>
<option value="Training">Training</option>
<option value="Trips">Trips</option>
<option value="Places/Airports">Places & Airports</option>
<option value="Buying">Buying an aircraft</option>
<option value="Technical/Building">Technical & Building</option>
<option value="Events">Events</option>
<option value="Other">Other</option>
</select>
</div>
<div class="input-group">
<span class="input-group-addon">Topic</span>
<input type="text" class="form-control" required maxlength="30" name="topic">
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Location <small> (optional)</small></span>
<input type="text" class="form-control" required name="location">
</div>
<textarea id="txtEditor" name="txtEditor"></textarea>
<div class="input-group">
<span class="input-group-addon" >Thumbnail</span>
<input type="file" class="form-control" name="thumbnail" required>
</div>
<button type="submit" id="post" name="post" >Post story</button>
</form>
<?php
function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
default: return false;
}
};
$file_name=$_FILES["thumbnail"]["name"];
$temp_name=$_FILES["thumbnail"]["tmp_name"];
$imgtype=$_FILES["thumbnail"]["type"];
$ext= GetImageExtension($imgtype);
$imagename=date("d-m-Y")."-".time().$ext;
$target_path = "thumbnails/".$imagename;
if(isset($_POST['post']) && move_uploaded_file($temp_name, $target_path) ){
$username=mysqli_real_escape_string($db_conx,$log_username);
$topic=mysqli_real_escape_string($db_conx,$_POST['topic']);
$story=mysqli_real_escape_string($db_conx,$_POST['txtEditor']);
$category=mysqli_real_escape_string($db_conx,$_POST['category']);
$location=mysqli_real_escape_string($db_conx,$_POST['location']);
$result=mysqli_query($db_conx,"INSERT INTO stories (`username`,`topic`,`story`,`category`,`location`,`thumbnail`) VALUES('$username','$topic','$story','$category','$location','$imagename')");
$resultgoto = mysqli_query($db_conx,"SELECT id from stories WHERE story = '$story' AND topic = '$topic' AND username = '$username'");
$gotorecord = mysqli_fetch_array($resultgoto);
header("Location: http://hangarflights.net46.net/stories/story.php?id=".$gotorecord['id']);
}
?>
答案 0 :(得分:1)
你确定它发布到你认为它的php文件吗?
尝试将表单标记更改为
<form method="POST" action="submitFile.php" id="newdiscussionform" enctype="multipart/form-data">
我也从id中取出了空间。