Data not inserting into database mysql/php [closed] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, October 2, 2022

Data not inserting into database mysql/php [closed]

Nothing wrong with the code connection works fine, the thing is form is redirecting to functions.php as all coding is there when I click button after entering data it just redirects to the functions.php page and nothing happens and also the image is not uploading in the folder. Below is the code and the image that shows on redirection

if(isset($_POST['btnpost']))
{
    $title=trim($_POST['titletxt']);
    $des=trim($_POST['destxt']);
    $acc_info=trim($_POST['accinfotxt']);
    $price=$_POST['pricetxt'];
 
    if(!empty($_FILES['img1']['name'])){ //img1

        $names=$_FILES['img1']['name'];
        $tmp_name=$_FILES['img1']['tmp_name'];
        $location='upload/';
        $path=$location.$names;
        
        if(move_uploaded_file($tmp_name,$path))
        {

            if(!empty($_FILES['img2']['name'])){ //img 2 

                $names=$_FILES['img2']['name'];
                $tmp_name=$_FILES['img2']['tmp_name'];
                $location='upload/';
                $path2=$location.$names;
                
                if(move_uploaded_file($tmp_name,$path2))
                {

                    if(!empty($_FILES['img3']['name'])){ //img 3 

                        $names=$_FILES['img3']['name'];
                        $tmp_name=$_FILES['img3']['tmp_name'];
                        $location='upload/';
                        $path3=$location.$names;
                        
                        if(move_uploaded_file($tmp_name,$path3))
                        {

   if(mysqli_query($conn, "INSERT INTO `accounts`(`acc_title`, `ln_des`, `acc_info`, `acc_price`, `img1`, `img2`, `img3`) VALUES('$title','$des','$acc_info','$price','$path','$path2','$path3')"))
   {
    header('location:index.php');
   }
   else
    {
        echo '<script>alert("Upload Error");</script>';
    }


    } 

        }

    } 

        }
    }
}

}


'''

[enter image description here][1]


  [1]: https://i.stack.imgur.com/AZvwh.png


source https://stackoverflow.com/questions/73920918/data-not-inserting-into-database-mysql-php

No comments:

Post a Comment