Form使用GET方法获取数据,但不使用POST方法
<form id="upload" method="post" action="" enctype="multipart/form-data" target="results">
<li class="action right"><a class="act" href="loader.php?q=show-songs">
<label>Name of Song</label>
<input type="text" name="name" placeholder="Song Name" required="">
<input type="hidden" name="q" value="add-new-song">
<label>is this albulm shows in top 20 Songs? <input type="checkbox" value="1" name="t20"></label>
<label>Select Album of This song</label>
<select name="album"><option value="41">70s Greatest Love</option><option value="42">coke studio</option><option value="43">krish 3</option><option value="44">Shuddh Desi Romance</option><option value="45">Warning (Original)</option><option value="46">Zanjeer</option><option value="47">Naiyaandi</option>
</select>
<li class="action right"><a class="act" href="loader.php?q=new-singer"><img src="../img/add2.png">Add new Singer</a></li>
<label>Select Singer Name </label>
<select name="singer"><option value="19">saim</option><option value="20">singer</option> </select>
<label>Song File</label>
<input type="file" class="buttonf" name="file1" required="">
<fieldset>
<legend>SEO</legend>
<input type="text" name="tags" placeholder="Key words and Seo Tags">
<textarea name="desc1" placeholder="Extra Details About Song"></textarea>
</fieldset>
<input type="submit" class="button" value="Add song Details" name="btn">
</form>
表格接收代码是
if(isset($_POST['btn']))
{
$desc=$_POST['desc1'];
$tags=$_POST['tags'];
$feature=0;
if(isset($_POST['t20']))
{
$feature=$_POST['t20'];
}
$album_id=$_POST['album'];
$name=$_POST['name'];
$singer=$_POST['singer'];
// $path="media/$fileName-$date";
$fileName = $_FILES["file1"]["name"]; // The file name
$fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder
$fileType = $_FILES["file1"]["type"]; // The type of file it is
$fileSize = $_FILES["file1"]["size"]; // File size in bytes
$fileErrorMsg = $_FILES["file1"]["error"]; // 0 for false... and 1 for true
$t=time();
$song_path="media/$t-$fileName";
move_uploaded_file($fileTmpLoc, "../$song_path");
if (!file_exists("../$song_path")) {
echo "ERROR: File not uploaded<br /><br />";
echo "Check folder permissions on the target uploads folder is 0755 or looser.<br /><br />";
echo "Check that your php.ini settings are set to allow over 2 MB files, they are 2MB by default.";
exit();
}
else
{
$msg=$this->song_insert($album_id,$singer,$name,$song_path,$feature,$desc,$tags);
echo"<strong><h1 style='color:white; font-family;font-family:Verdana, Geneva, sans-serif; font-weight:100px;'></strong>$msg</strong></h1>";}
exit();
}
但它会给出错误
注意:未定义的索引:第288行的D:\ new \ xampp \ htdocs \ xampp \ projects \ music \ admin \ class.php中的desc1
注意:未定义的索引:第289行的D:\ new \ xampp \ htdocs \ xampp \ projects \ music \ admin \ class.php中的相册
注意:未定义的索引:第295行的D:\ new \ xampp \ htdocs \ xampp \ projects \ music \ admin \ class.php中的标签
注意:未定义的索引:第296行的D:\ new \ xampp \ htdocs \ xampp \ projects \ music \ admin \ class.php中的名称 注意:未定义的索引:第281行的D:\ new \ xampp \ htdocs \ xampp \ projects \ music \ admin \ class.php中的file1
注意:未定义的索引:第298行的D:\ new \ xampp \ htdocs \ xampp \ projects \ music \ admin \ class.php中的相册