表单使用 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();
}
但它给出了错误
注意:未定义的索引:D:\new\xampp\htdocs\xampp\projects\music\admin\class.php 中的 desc1 在第 288 行
注意:未定义索引:第 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 中的名称 注意:未定义的索引:D:\new\xampp\htdocs\xampp\projects\ 中的 file1第 281 行的 music\admin\class.php
注意:未定义索引:第 298 行 D:\new\xampp\htdocs\xampp\projects\music\admin\class.php 中的专辑