I am trying to make a form and retrieve the values of the form on another PHP file by POST method.
but Unfortunately it doesn't seem to work.
below is the form input file
<form action="uploadimage.php" method="POST" enctype="multipart/form-data">
<div align="center"><table border=0>';
echo"<tr><td>Caption: </td><td><input type='text' name='caption'></td></tr>
<tr><td>Album</td><td>";
$Query='SELECT * FROM `gallery`';
$result=mysqli_query($connection,$Query);
echo'<select name="albums">';
$count=0;
$previous=-1;
while($data=mysqli_fetch_array($result))
{
if($previous<$data['album'])
{
echo "<option value=".$data['album'].">".$data['album']."</option>";
$previous=$data['album'];
}
if($count<=$data['album'])
{
$count=$data['album']+1;
}
}
echo "<option value='.$count.'>New Album</option>";
echo"</select></td></tr>
<tr><td>Picture: </td><td><input type='file' name='photo'></td></tr>
<tr><td></td><td><input type='submit' name='upload_btn' value='upload'></td></tr>
</table></div>
</form>
Don't mind the other codes, I am just worried about the transfer of the input values of the form.
Here is the code to receive the values of the form in another PHP file
require_once"connection.php";
$target_Path='img/displays/';
$caption=$_POST['caption'];
$albums=$_POST['albums'];
$target_Path = $target_Path.basename($_FILES['photo']['name'] );
move_uploaded_file( $_FILES['photo']['tmp_name'], $target_Path);
$withoutExt = preg_replace("/\\.[^.\\s]{3,4}$/", "", $target_Path);
mysqli_query($connection,"INSERT INTO `ett`.`gallery` (`id` ,`album`,`name`,`path`)VALUES (NULL,'".$albums."','".$caption."','".$withoutExt."')");
and the error which I receive is as follows
Notice: Undefined index: caption in C:\wamp\www\ETT Logo\Controlpanel\uploadimage.php on line 12
I receive the above error for all of the inputs in the form. and the values are not being transmitted.