I have an upload form at the moment for a photo upload which is handled in a separate file. In the separate file there are a few different error checking IF statements and I currently am headering the user to an error page which is not very user friendly. How can I pass the php value back to the form?
<form id="avatar_form" action="photo_system.php" method="post" enctype="multipart/form-data">
<h1>Change avatar</h1>
<input type="file" name="avatar" required>
<p><input type="submit" value="Upload"></p>
</form>
Here is some of the PHP I wont paste it all because there is so much
if($width < 10 || $height < 10){
header("location: ../message.php?msg=ERROR: That image has no dimensions");
exit();
}
$db_file_name = rand(100000000000,999999999999).".".$fileExt;
if($fileSize > 1048576) {
header("location: ../message.php?msg=ERROR: Your image file was larger than 1mb");
exit();
} else if (!preg_match("/\.(gif|jpg|png)$/i", $fileName) ) {
header("location: ../message.php?msg=ERROR: Please only JPG, GIF or PNG images");
exit();
} else if ($fileErrorMsg == 1) {
header("location: ../message.php?msg=ERROR: An unknown error occurred");
exit();
}