0

I'm trying to insert data from a html form into a sql database. when I click submit it should put the data the form into a table named jin but it is failing to do so. I am terribly new to php and sql so it may have been a stupid mistake.

<form action="insertform.php" method="post">
   Jin Number:<input type="text" name="jin_n"><br>
   Jin Name:<input type="text" name="jin_name"><br>
   Jin Alt(No Kanji):<input type="text" name="jin_alt"><br>
   Number of pages:<input type="text" name="jin_p"><br>
   Summary:<input type="text" name="jin_s"><br>
   <input type="submit" name="Enter">
</form>
<?php
   include "dbconnect.php";
   if(isset($_POST['Enter'])){
//
    $sqli_code="INSERT INTO jin (JIN_NUM, JIN_NAME, JIN_ALT`, JIN_PGS, JIN_SUM) VALUES(
    NUL,
   '$_POST[jin_name]',
   '$_POST[jin_alt]',
   '$_POST[jin_p]',
   '$_POST[jin_s]')";   
    echo "<br><br><br> SQLI_CODE: ", $sqli_code;    
    mysqli_query($dbconnect,$sqli_code);    
   };
?>

//dbconnect.php
<?php
   $dbconnect = mysqli_connect("localhost","root","","nururu");
    if(mysqli_connect_errno())
       {
        echo 'Connection Error' .msqli_connect_error();
        exit;
        }
 ?>
Isaac Bennetch
  • 11,061
  • 2
  • 28
  • 40
Chanヨネ
  • 673
  • 1
  • 6
  • 11

2 Answers2

1

change

(JIN_NUM, JIN_NAME, JIN_ALT`, JIN_PGS, JIN_SUM)

to

(JIN_NUM, JIN_NAME, JIN_ALT, JIN_PGS, JIN_SUM)

You can see a ' extra in this.

and NUL? I hope you meant NULL

Danyal Sandeelo
  • 11,641
  • 10
  • 42
  • 69
0

Some silly mistake in code. this code help you.

<?php
    include "dbconnect.php";
    if(isset($_POST['Enter'])){

    $sqli_code="INSERT INTO jin (JIN_NUM, JIN_NAME, JIN_ALT, JIN_PGS, JIN_SUM) VALUES(
    '',
   '$_POST[jin_name]',
   '$_POST[jin_alt]',
   '$_POST[jin_p]',
   '$_POST[jin_s]')";   
    echo "<br><br><br> SQLI_CODE: ", $sqli_code;    
    mysqli_query($dbconnect,$sqli_code);    
   };
 ?>
Mukesh Singh Thakur
  • 1,072
  • 1
  • 9
  • 20