title: How to fix undefined error in php
body: <p>I have a problem to fix this type error, I am also declare the variable the its given a problem.</p>
  
  <p>This is my complete file:</p>
  
  <pre><code>$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'] &amp;&amp; $_FILES['image']['size'] &lt; $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 "&lt;script&gt;alert('Banner Added Successfully !');&lt;/script&gt;";
                      $success='&lt;div class="alert alert-success" role="alert"&gt;&lt;strong&gt;Well done!&lt;/strong&gt; You successfully add the banner.&lt;/div&gt;';
  
                      // echo "&lt;script&gt;document.location.href='front_banner.php'&lt;/script&gt;";
                  } else {
                      $error1='&lt;div class="alert alert-danger" role="alert"&gt;&lt;strong&gt;Oh snap!&lt;/strong&gt; Change a few things up and try submitting again.&lt;/div&gt;';
                      //echo "&lt;script&gt;document.location.href='front_banner.php'&lt;/script&gt;";
                  }
              } else {
                  $error1='&lt;div class="alert alert-danger" role="alert"&gt;&lt;strong&gt;Oh snap!&lt;/strong&gt; Change a few things up and try submitting again.&lt;/div&gt;';
                  //echo "&lt;script&gt;document.location.href='front_banner.php'&lt;/script&gt;";
              }
          } else {
              $error1='&lt;div class="alert alert-danger" role="alert"&gt;&lt;strong&gt;Oh snap!&lt;/strong&gt; Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.&lt;/div&gt;';         
          }
      } else {
          $error1='&lt;div class="alert alert-danger" role="alert"&gt;&lt;strong&gt;Oh snap!&lt;/strong&gt; Sorry, Please fill the Field&lt;/div&gt;';
      }
  }
  </code></pre>
  
  <p>This is my output:</p>
  
  <blockquote>
    <p><br /> <b>Notice</b>: Undefined index: x in
    <b>E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on
    line <b>28</b><br /> <br /> <b>Notice</b>: Undefined index: y in
    <b>E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on
    line <b>29</b><br /> <br /> <b>Notice</b>: Undefined index: w in
    <b>E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on
    line 30</b><br /> <br /> Notice</b>: Undefined index: h in
    E:\xampp\htdocs\novus_admin_panel\web\front_banner.php on
    line 31</b><br /></p>
  </blockquote>
  
  <p>What am I doing wrong?</p>