Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Upload content onto Bootstrap card

Upload content onto Bootstrap card

Scheduled Pinned Locked Moved Web Development
phpcssdatabasequestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MekaC
    wrote on last edited by
    #1

    Hey there!!!

    Im trying to attach image upload to bootstrap card(home.php) as well place the image in gallery(gallery.php). When I hit submit Im taken to a blank page instead of seeing image displayed on home page. Here is my code:

    ```

    Upload Image

    Close

    query($query);

    // Loop thru comments and display all of them
    while($row = $result->fetch_array(MYSQLI_ASSOC) ) {
    printf("%s (%s)\n", $row["username"], $row["comment"],$row["image"]);
    ?>

        [
            
    
                 ![...](<?php echo $fetch['location']?>)
            
    
            
    
        ](pro.php)
    

    ```

    ```
    5242880){
    echo "alert('File too large!')";
    echo "window.location = 'home.php'";
    }else{
    if(move_uploaded_file($image_temp, $path)){
    mysqli_query($conn, "INSERT INTO `image` VALUES('', '$name', '$path')") or die(mysqli_error());
    echo "alert('Image uploaded!')";
    echo "window.location = 'home.php'";
    }
    }
    }else{
    echo "alert('Invalid image format!')";
    echo "

    Richard DeemingR P 2 Replies Last reply
    0
    • M MekaC

      Hey there!!!

      Im trying to attach image upload to bootstrap card(home.php) as well place the image in gallery(gallery.php). When I hit submit Im taken to a blank page instead of seeing image displayed on home page. Here is my code:

      ```

      Upload Image

      Close

      query($query);

      // Loop thru comments and display all of them
      while($row = $result->fetch_array(MYSQLI_ASSOC) ) {
      printf("%s (%s)\n", $row["username"], $row["comment"],$row["image"]);
      ?>

          [
              
      
                   ![...](<?php echo $fetch['location']?>)
              
      
              
      
          ](pro.php)
      

      ```

      ```
      5242880){
      echo "alert('File too large!')";
      echo "window.location = 'home.php'";
      }else{
      if(move_uploaded_file($image_temp, $path)){
      mysqli_query($conn, "INSERT INTO `image` VALUES('', '$name', '$path')") or die(mysqli_error());
      echo "alert('Image uploaded!')";
      echo "window.location = 'home.php'";
      }
      }
      }else{
      echo "alert('Invalid image format!')";
      echo "

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query. PHP: SQL Injection - Manual[^] PHP: Prepared statements and stored procedures - Manual[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • M MekaC

        Hey there!!!

        Im trying to attach image upload to bootstrap card(home.php) as well place the image in gallery(gallery.php). When I hit submit Im taken to a blank page instead of seeing image displayed on home page. Here is my code:

        ```

        Upload Image

        Close

        query($query);

        // Loop thru comments and display all of them
        while($row = $result->fetch_array(MYSQLI_ASSOC) ) {
        printf("%s (%s)\n", $row["username"], $row["comment"],$row["image"]);
        ?>

            [
                
        
                     ![...](<?php echo $fetch['location']?>)
                
        
                
        
            ](pro.php)
        

        ```

        ```
        5242880){
        echo "alert('File too large!')";
        echo "window.location = 'home.php'";
        }else{
        if(move_uploaded_file($image_temp, $path)){
        mysqli_query($conn, "INSERT INTO `image` VALUES('', '$name', '$path')") or die(mysqli_error());
        echo "alert('Image uploaded!')";
        echo "window.location = 'home.php'";
        }
        }
        }else{
        echo "alert('Invalid image format!')";
        echo "

        P Offline
        P Offline
        phil o
        wrote on last edited by
        #3

        $mysqli = new mysqli("'');

        This will cause issues if it is not just a typo on your question.

        "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups