I have a problem to fix this type error, I am also declare the variable the its given a problem.
This is my complete file:
$success='';
$error1='';
$valid_exts = array('jpeg', 'jpg', 'png', 'gif');
$max_file_size = 2000* 1024; #200kb
$nw = $nh = 50;
# image with # height
if(isset($_REQUEST['submit']))
{
$title=$_REQUEST['title'];
$date=date('d-M-Y');
/****prod image*******************************/
$fn1=$_FILES['image']['name'];
$fs1=$_FILES['image']['size'];
$ftemp1=$_FILES['image']['tmp_name'];
$img_type1=$_FILES['image']['type'];
if(! $_FILES['image']['error'] && $_FILES['image']['size'] < $max_file_size) {
$ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION));
if (in_array($ext, $valid_exts))
{
// Check if file already exists
$path = 'image/thumb/'.$fn1;
$size = getimagesize($_FILES['image']['tmp_name']);
$x = (int) $_POST['x'];
$y = (int) $_POST['y'];
$w = (int) $_POST['w'] ? $_POST['w'] : $size[0];
$h = (int) $_POST['h'] ? $_POST['h'] : $size[1];
$data = file_get_contents($_FILES['image']['tmp_name']);
$vImg = imagecreatefromstring($data);
$dstImg = imagecreatetruecolor($nw, $nh);
imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw, $nh, $w, $h);
imagejpeg($dstImg, $path);
imagedestroy($dstImg);
if(move_uploaded_file ($ftemp1,"image/$fn1")){
$result="INSERT INTO add_banner VALUES ('','$title','$fn1','$date')";
if(mysql_query($result)){
//echo "<script>alert('Banner Added Successfully !');</script>";
$success='<div class="alert alert-success" role="alert"><strong>Well done!</strong> You successfully add the banner.</div>';
// echo "<script>document.location.href='front_banner.php'</script>";
} else {
$error1='<div class="alert alert-danger" role="alert"><strong>Oh snap!</strong> Change a few things up and try submitting again.</div>';
//echo "<script>document.location.href='front_banner.php'</script>";
}
} else {
$error1='<div class="alert alert-danger" role="alert"><strong>Oh snap!</strong> Change a few things up and try submitting again.</div>';
//echo "<script>document.location.href='front_banner.php'</script>";
}
} else {
$error1='<div class="alert alert-danger" role="alert"><strong>Oh snap!</strong> Sorry, only JPG, JPEG, PNG & GIF files are allowed.</div>';
}
} else {
$error1='<div class="alert alert-danger" role="alert"><strong>Oh snap!</strong> Sorry, Please fill the Field</div>';
}
}
This is my output:
Notice: Undefined index: x in E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on line 28
Notice: Undefined index: y in E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on line 29
Notice: Undefined index: w in E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on line 30
Notice: Undefined index: h in E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on line 31
What am I doing wrong?