title: I want to insert data in database but it it not working .... my code is mentioned
body: <p>I know that i messed up the code and getting undefined index errors and can't connect to database error also thanks in advance</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php include("header.php");
              ?&gt;
  
  &lt;?php
   
   
   $target_dir = "admin/";
   $file = $_FILES['image']['name'];
   $path = pathinfo($file);
   $filename = $path['filename'];
   $temp_name = $_FILES['image']['tmp_name'];
   $rand = rand(0000,9999);
   $path_filename_ext = $target_dir.$filename.$rand;
   
    
   if(! get_magic_quotes_gpc() ) {
   
                 $name = addslashes ($_POST['name']);
                 $phone = addslashes ($_POST['phone']);
         $password = addslashes ($_POST['password']);
                 $email = addslashes ($_POST['email']);
         $role = addslashes ($_POST['role']);
         $image = addslashes (move_uploaded_file($temp_name,$path_filename_ext));
  
              }else {
                 $name = $_POST['name'];
                 $phone = $_POST['phone'];
         $password = $_POST['password'];
                 $email = $_POST['email'];
         $role = $_POST['role'];
         $image =  move_uploaded_file($temp_name,$path_filename_ext);
              }
              
            
              
  $sql = "INSERT INTO admin ". "(a_name, a_phone, a_password, a_email, a_role, a_image) ". "VALUES('$name','$phone','$password','$email','$role','$image' NOW())";
                 
                          // make project the current db
  $db_selected = mysql_select_db('project', $conn);
  if (!$db_selected) {
      die ('Can\'t use project : ' . mysql_error());
  }
              $retval = mysql_query( $sql, $conn );
              
              if(! $retval ) {
                 die('Could not enter data: ' . mysql_error());
              }
              
              echo "Entered data successfully\n";
              
              mysql_close($conn);
           
  ?&gt;
  
    &lt;section&gt;
  
      &lt;div class="container-fluid"&gt;
        &lt;div class="row"&gt;
  
          &lt;form name="myForm" action="&lt;?php $_PHP_SELF ?&gt;" method="post" enctype="multipart/form-data"&gt;
  
            &lt;div class="col-xs-6 col-sm-6"&gt;
              &lt;div class="form-horizontal"&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="inputEmail3" class="col-sm-2 control-label"&gt;Name&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                    &lt;input type="text" class="form-control" id="inputTextBox" placeholder="Name" name="name" required/&gt;
  
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="inputPassword3" class="col-sm-2 control-label"&gt;Password&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                    &lt;input type="password" class="form-control" id="password" placeholder="Password" name="password" required/&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;label for="inputPassword3" class="col-sm-2 control-label"&gt;Strength&lt;/label&gt;
                  &lt;label class="col-sm-6 control-label" id="result" style="padding-top:1%;"&gt;
      &lt;/label&gt;
                &lt;/div&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;label for="inputEmail3" class="col-sm-2 control-label"&gt;Email&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                    &lt;input type="email" class="form-control" id="txtEmail" placeholder="Email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" name="email" required/&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  
              &lt;/div&gt;
  
  
            &lt;/div&gt;
  
  
  
  
  
            &lt;div class="col-xs-6 col-sm-6"&gt;
              &lt;div class="form-horizontal"&gt;
  
  
  
                &lt;div class="form-group"&gt;
                  &lt;label for="inputPassword3" class="col-sm-2 control-label"&gt;Role&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt;
                    &lt;select class="form-control" name="role"&gt;
    &lt;option value=""&gt;&lt;/option&gt;
    &lt;option value="Admin"&gt;Admin&lt;/option&gt;
    &lt;option value="Vendor"&gt;Vendor&lt;/option&gt;
    &lt;option value="Subscriber"&gt;Subscriber&lt;/option&gt;
    
  &lt;/select&gt; &lt;/div&gt;
                &lt;/div&gt;
  
  
                &lt;div class="form-group"&gt;
                  &lt;label for="exampleInputFile" class="col-sm-2 control-label"&gt;Image&lt;/label&gt;
                  &lt;div class="col-sm-10"&gt; &lt;input type="file" id="exampleInputFile" name="image"&gt;
                    &lt;p class="help-block"&gt;Max Size 1 MB .&lt;/p&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  
              &lt;/div&gt;
  
  
              &lt;div class="form-group"&gt;
                &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                  &lt;input type="submit" name="Sign in" value="Sign in" class="btn btn-default"&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
          &lt;/form&gt;
  
          &lt;/div&gt;
  
  
  
        &lt;/div&gt;
      &lt;/div&gt;
  
  
  
  
  
  
  
  
  
    &lt;/section&gt;
  
    &lt;?php include("footer.php");
   ?&gt;</code></pre>
  </div>
  </div>
  
  I know that i messed up the code and getting undefined index errors and can't connect to database error also thanks in advance</p>