php help , Notice: Undefined index: product_title in C:\xampp\htdocs\ecommerce\admin_

rudr@

Well-known member
  • Oct 30, 2010
    1,581
    149
    63
    <?php

    // getting the text data from the field
    global $product_title , $product_cat, $product_brand;

    if(isset($_POST['insert_post'])){
    $product_title=$_POST['product_title'];
    $product_cat=$_POST['product_cat'];
    $product_brand=$_POST['product_brand'];
    $product_price=$_POST['product_price'];
    $product_desc=$_POST['product_desc'];
    $product_keywords=$_POST['product_keywords'];

    }
    //getting the image from the field
    $product_image = $_FILES['product_image']['name'];
    $product_image_tmp = $_FILES['product_image']['tmp_name'];

    echo $insert_product = "insert into products
    (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords)
    values(' $product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_image','$product_keywords')";



    ?>

    Notice: Undefined index: product_title in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 107

    Notice: Undefined index: product_cat in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 108

    Notice: Undefined index: product_brand in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 109

    Notice: Undefined index: product_price in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 110

    Notice: Undefined index: product_desc in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 111

    Notice: Undefined index: product_keywords in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 112

    Notice: Undefined index: product_image in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 116

    Notice: Undefined index: product_image in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 117
    insert into products (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values(' ','','','','','','')

    me error eka hadaganne kohomada mcnla...
     

    AloneGuy90

    Member
    Sep 3, 2014
    1,791
    243
    0
    product_title POST variable eka ube script eke thibbata, eka submit wennathi awlak thiyenne. balapan form eke input field name eka hariyatama post variable name ekata samanada kiyala.
     
    • Like
    Reactions: rudr@

    Barry Allen

    Member
    Oct 15, 2016
    2,855
    139
    0
    Central City
    product_title POST variable eka ube script eke thibbata, eka submit wennathi awlak thiyenne. balapan form eke input field name eka hariyatama post variable name ekata samanada kiyala.

    :nerd::eek:

    උබ ඇත්තටම script විකුණනවද codecanyon එකේ :rolleyes::confused:

    ඔය ෆෝම් එක submit වෙනෙන් නැහැ...ඒ නිසයි එකම variable එකක්වත් අරන් නැත්තේ ..එක්කෝ method = post දාලා නැහැ :dull:

    PHP:
    echo $insert_product = "insert into products
    (product_cat,product_brand,product_title,product_p rice,product_desc,product_image,product_keywords)
    values(' $product_cat','$product_brand','$product_title','$ product_price','$product_desc','$product_image','$ product_keywords')";

    Space එකක් තියෙනවා :baffled:
    $ product_price
    $ product_keywords

    :angry:

    PHP:
    <?php
    
    // getting the text data from the field
    ඔය විදියට blank space තියන්න එපා...?> වහනවා නම් අන්තිමට..:dull:
     
    Last edited:
    • Like
    Reactions: rudr@

    AloneGuy90

    Member
    Sep 3, 2014
    1,791
    243
    0
    :nerd::eek:

    උබ ඇත්තටම script විකුණනවද codecanyon එකේ :rolleyes::confused:

    woocommerce themes on themeforest :yes::yes::yes:
    planned to release a shopify theme in coming month. :yes::D

    මොකෝ උබ ඇත්තටමද කියල ඇහුවෙ? අඩෝ මම පියන් තමයි. ඒත් පියන් වෙන්න කලින් කමේ මේව හරියැ. :rofl:
     
    Last edited:

    Barry Allen

    Member
    Oct 15, 2016
    2,855
    139
    0
    Central City
    woocommerce themes on themeforest :yes::yes::yes:
    planned to release a shopify theme in coming month. :yes::D

    මොකෝ උබ ඇත්තටමද කියල ඇහුවෙ? අඩෝ මම පියන් තමයි. ඒත් පියන් වෙන්න කලින් කමේ මේව හරියැ. :rofl:

    නැහැ උබ දීපු උත්තරේ නිසා ඇහුවේ..

    theme විතරද විකුනන්නේ,codecanyon නැද්ද :P

    පිටරට විදියට profile හදන එක නම් TOS විරුද්දයි...එත් සුද්දෝ නම් ගන්නවා එහෙම උනාම :D
     

    rudr@

    Well-known member
  • Oct 30, 2010
    1,581
    149
    63
    <!DOCTYPE>
    <?php
    include("includes/db.php");
    ?>

    <html>
    <head>
    <title>Inserting Product</title>
    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>tinymce.init({ selector:'textarea' });</script>

    </head>
    <body bgcolor="skyblue">
    <form action="insert_product.php" method="post" encrypt="multipart/form-data">
    <table align="center" width="750" border="2" bgcolor="Orange">
    <tr align="center">
    <td colspan="7"><h2>Insert New Post Here</h2></td>

    <tr>
    <td align="right"><b>Product Title:</b> </td>
    <td><input type="text" name="Product_title" size="60" required/></td>
    </tr>
    <tr>
    <td align="right"><b>Product Category:</b> </td>
    <td>

    <select name="product_cat">
    <option>Select a Category</option>
    <?php
    // select categories
    $get_cats= "select * from categories ";
    $run_cats = mysqli_query($con,$get_cats);

    while ($row_cats= mysqli_fetch_array($run_cats)){

    $cat_id = $row_cats['cat_id'];
    $cat_title = $row_cats['cat_title'];

    echo "<option value='$cat_id'>$cat_title</option>";
    }
    ?>

    </select>

    </td>
    </tr>
    <tr>
    <td align="right"><b>Product Brand:</b> </td>
    <td>
    <select name="product_brand">
    <option>Select a Brand</option>
    <?php
    // select brands
    $get_brands= "select * from brands ";
    $run_brands = mysqli_query($con,$get_brands);

    while ($row_brands= mysqli_fetch_array($run_brands)){

    $brand_id = $row_brands['brand_id'];
    $brand_title = $row_brands['brand_title'];


    echo "<option value='$brand_id'>$brand_title</option>";
    }
    ?>

    </select>

    </td>
    </tr>
    <tr>
    <td align="right"><b>Product Image:</b> </td>
    <td><input type="file" name="Product_image"></td>
    </tr>
    <tr>
    <td align="right"><b>Product Price:</b> </td>
    <td><input type="text" name="Product_price"></td>
    </tr>
    <tr>
    <td align="right"><b>Product Description: </b></td>
    <td>
    <textarea name="product_desc" cols="30" rows="10" ></textarea>
    </td>
    </tr>
    <tr>
    <td align="right"><b>Product Keywords:</b> </td>
    <td><input type="text" name="Product_keywords" size="60"></td>
    </tr>
    <tr align="center">

    <td colspan="8"><input type="submit" name="insert_post" value="Insert Product Now"></td>
    </tr>

    </tr>
    </table>
    </form>


    </body>
    </html>
    <?php

    // getting the text data from the field
    global $product_title , $product_cat, $product_brand;

    if(isset($_POST['insert_post'])){
    $product_title=$_POST['product_title'];
    $product_cat=$_POST['product_cat'];
    $product_brand=$_POST['product_brand'];
    $product_price=$_POST['product_price'];
    $product_desc=$_POST['product_desc'];
    $product_keywords=$_POST['product_keywords'];

    }
    //getting the image from the field
    $product_image = $_FILES['product_image']['name'];
    $product_image_tmp = $_FILES['product_image']['tmp_name'];

    echo $insert_product = "insert into products
    (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords)
    values(' $product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_image','$product_keywords')";





    ?>
     

    AloneGuy90

    Member
    Sep 3, 2014
    1,791
    243
    0
    නැහැ උබ දීපු උත්තරේ නිසා ඇහුවේ..

    theme විතරද විකුනන්නේ,codecanyon නැද්ද :P

    පිටරට විදියට profile හදන එක නම් TOS විරුද්දයි...එත් සුද්දෝ නම් ගන්නවා එහෙම උනාම :D

    නැහැ බන්. තීම් ගහන එක ලේසි එකක් හදාගත්තම ටිකක් වෙනස් කරල වෙන නමක් දාල දැම්ම හැකි. අනිත් එක සේල්ස් වැඩියි. මම ගහන එකකින් මට සේල්ස් 300ක් විතර තිබ්බොත් ඇති.

    ඔව් මට දෙකක් තියෙනව දැන් යූස් කරන එක US, පේපැල් ගන්නව.
     

    Barry Allen

    Member
    Oct 15, 2016
    2,855
    139
    0
    Central City
    <!DOCTYPE>
    <?php
    include("includes/db.php");
    ?>

    <html>
    <head>
    <title>Inserting Product</title>
    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>tinymce.init({ selector:'textarea' });</script>

    </head>
    <body bgcolor="skyblue">
    <form action="insert_product.php" method="post" encrypt="multipart/form-data">
    <table align="center" width="750" border="2" bgcolor="Orange">
    <tr align="center">
    <td colspan="7"><h2>Insert New Post Here</h2></td>

    <tr>
    <td align="right"><b>Product Title:</b> </td>
    <td><input type="text" name="Product_title" size="60" required/></td>
    </tr>
    <tr>
    <td align="right"><b>Product Category:</b> </td>
    <td>

    <select name="product_cat">
    <option>Select a Category</option>
    <?php
    // select categories
    $get_cats= "select * from categories ";
    $run_cats = mysqli_query($con,$get_cats);

    while ($row_cats= mysqli_fetch_array($run_cats)){

    $cat_id = $row_cats['cat_id'];
    $cat_title = $row_cats['cat_title'];

    echo "<option value='$cat_id'>$cat_title</option>";
    }
    ?>

    </select>

    </td>
    </tr>
    <tr>
    <td align="right"><b>Product Brand:</b> </td>
    <td>
    <select name="product_brand">
    <option>Select a Brand</option>
    <?php
    // select brands
    $get_brands= "select * from brands ";
    $run_brands = mysqli_query($con,$get_brands);

    while ($row_brands= mysqli_fetch_array($run_brands)){

    $brand_id = $row_brands['brand_id'];
    $brand_title = $row_brands['brand_title'];


    echo "<option value='$brand_id'>$brand_title</option>";
    }
    ?>

    </select>

    </td>
    </tr>
    <tr>
    <td align="right"><b>Product Image:</b> </td>
    <td><input type="file" name="Product_image"></td>
    </tr>
    <tr>
    <td align="right"><b>Product Price:</b> </td>
    <td><input type="text" name="Product_price"></td>
    </tr>
    <tr>
    <td align="right"><b>Product Description: </b></td>
    <td>
    <textarea name="product_desc" cols="30" rows="10" ></textarea>
    </td>
    </tr>
    <tr>
    <td align="right"><b>Product Keywords:</b> </td>
    <td><input type="text" name="Product_keywords" size="60"></td>
    </tr>
    <tr align="center">

    <td colspan="8"><input type="submit" name="insert_post" value="Insert Product Now"></td>
    </tr>

    </tr>
    </table>
    </form>


    </body>
    </html>
    <?php

    // getting the text data from the field
    global $product_title , $product_cat, $product_brand;

    if(isset($_POST['insert_post'])){
    $product_title=$_POST['product_title'];
    $product_cat=$_POST['product_cat'];
    $product_brand=$_POST['product_brand'];
    $product_price=$_POST['product_price'];
    $product_desc=$_POST['product_desc'];
    $product_keywords=$_POST['product_keywords'];

    }
    //getting the image from the field
    $product_image = $_FILES['product_image']['name'];
    $product_image_tmp = $_FILES['product_image']['tmp_name'];

    echo $insert_product = "insert into products
    (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords)
    values(' $product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_image','$product_keywords')";



    ?>

    input name වල තියෙන්නේ කැපිටල් මුලින්,එත් code එකේ ගන්නේ වෙන එකක්..
    Product_price =>$_POST['product_price'];
    Product_keywords =>$_POST['product_keywords'];
     

    AloneGuy90

    Member
    Sep 3, 2014
    1,791
    243
    0
    අඩෝ closing tag එක ඕන නෑ බන් නිකන් unwanted whitespaces add wenawa and output buffering on wenna puluwan. so eka avoid karapan php witharaknam script eke thiyenne. eka good programming practice ekak.
     

    Barry Allen

    Member
    Oct 15, 2016
    2,855
    139
    0
    Central City
    නැහැ බන්. තීම් ගහන එක ලේසි එකක් හදාගත්තම ටිකක් වෙනස් කරල වෙන නමක් දාල දැම්ම හැකි. අනිත් එක සේල්ස් වැඩියි. මම ගහන එකකින් මට සේල්ස් 300ක් විතර තිබ්බොත් ඇති.

    ඔව් මට දෙකක් තියෙනව දැන් යූස් කරන එක US, පේපැල් ගන්නව.

    එල එල...තීම් නම් 100ක් වගේනම් එකකින් විකුණා ගන්න පුළුවන් ලස්සන තියෙනවා..ඔකේ ඉන්න උන් ඔහේ ගන්නවා :rofl::rofl:

    කොහොම හරි Avada වගේ එකක් ගහපන්.....උබටත් හමර් එකක් බස්සන්න පුළුවන් :P:P
     
    Last edited:

    rudr@

    Well-known member
  • Oct 30, 2010
    1,581
    149
    63
    අඩෝ closing tag එක ඕන නෑ බන් නිකන් unwanted whitespaces add wenawa and output buffering on wenna puluwan. so eka avoid karapan php witharaknam script eke thiyenne. eka good programming practice ekak.

    koi closing tag ekada bn..
     

    rudr@

    Well-known member
  • Oct 30, 2010
    1,581
    149
    63
    input name වල තියෙන්නේ කැපිටල් මුලින්,එත් code එකේ ගන්නේ වෙන එකක්..
    Product_price =>$_POST['product_price'];
    Product_keywords =>$_POST['product_keywords'];

    eth nane bn,,,
     

    Barry Allen

    Member
    Oct 15, 2016
    2,855
    139
    0
    Central City
    eth nane bn,,,

    ඕක ඔහොම හොයන්න අමාරුයි බන්.මුලින් කිව්වා වගේ ඔය ෆෝම් එක submit වෙන්නේ නැති case එකකුත් තියෙනවා..ලෙඩ ගොඩයිනෙ..

    zip කරලා db එකත් එක්ක එවපන්..හදලා එවන්නම්
     

    rudr@

    Well-known member
  • Oct 30, 2010
    1,581
    149
    63
    ඕක ඔහොම හොයන්න අමාරුයි බන්.මුලින් කිව්වා වගේ ඔය ෆෝම් එක submit වෙන්නේ නැති case එකකුත් තියෙනවා..ලෙඩ ගොඩයිනෙ..

    zip කරලා db එකත් එක්ක එවපන්..හදලා එවන්නම්

    mail ekak deepanko mcn..