Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to insert data to sql from my form but the data is not going into my sql table. Also I'm not getting errors. Here is what I have :

<?php
mysqli_select_db($connect, "prekes");
if(isset($_POST['submit']))
{
     $pavad =  $_POST['pavad'];
     $Gamintojas =  $_POST['Gamintojas'];
     $Spalva =  $_POST['Spalva'];
     $Kiekis =  $_POST['Kiekis'];
     $Blizgumas = $_POST['Blizgumas'];
     $Kaina =  $_POST['Kaina'];
     $Kategorija =  $_POST['Kategorija'];
     $sandely =  $_POST['sandely'];

$query="
INSERT INTO prekes 
( pavad, Gamintojas, Spalva, Kiekis
, Blizgumas, Kaina, Kategorija, sandely) 
VALUES 
( '$pavad', '$Gamintojas', '$Spalva', '$Kiekis'
, '$Blizgumas', '$Kaina', '$Kategorija', '$sandely')
";

      if(mysqli_query($connect,$query))
      {
        echo "prideta";
      }else {
        echo"nope";
      }
}
?>

I've also putting my main.php code where I put my connection and tables at

</table>
<div class="prekiu_lentele">
<div class="lent">
<table class="lenetele_prekems" align="center">
<form action="insert.php" method="post">
<form action="update.php" method="get">
<tr>
    <th>Pavadinimas:<input type="text" name="pavad"></tr>
    <th>Gamintojas:<input type="text" name="Gamintojas"></tr>
    <th>Spalva:<input type="text" name="Spalva"></tr>
    <th>Kiekis:
      <select name="Kiekis">
        <option value="1l">1 l</option>
        <option value="2l">2 l</option>
        <option value="5l">5 l</option>
        <option value="10l">10 l</option>
      </select></tr>
    </tr>
    <tr>
    <th>Blizgumas:<input type="text" name="Blizgumas"></tr>
    <th>Kaina:<input type="text" name="Kaina"></tr>
    <th>Kategorija:<input type="text" name="Kategorija"></tr>
    <th>Kiekis sandelyje:<input type="text" name="sandely"></tr>
    </tr>
    <tr>
      <th ><input type="submit"; style="width: 300px"; value="Insert"  name="submit" ></th>
</tr>
</form>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
789 views
Welcome To Ask or Share your Answers For Others

1 Answer

I got it working, my path to sql database was wrong -_-. mysqli_select_db($connect, "prekes"); -> mysqli_select_db($connect, "produktai"); Noob mistakes..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...