Я получаю ошибку, когда нажимаю кнопку отправить в своей форме.
Я получаю ошибку, когда нажимаю кнопку отправить в своей форме.
<?php // php code to Insert data into mysql database from input text if(isset($_POST['insert'])) { $hostname = "localhost"; $username = "coleman"; $password = "Kkkholiday@33"; $databaseName = "test"; // get values form input text and number $id = $_POST['id']; $name = $_POST['name']; $vin = $_POST['vin']; // connect to mysql database using mysqli $connect = mysqli_connect($localhost, $coleman, $Kkkholiday@33, $test); // mysql query to insert data INSERT INTO `test`(`id`, `name`, `vin`) VALUES ([id],[name],[vin]) $result = mysqli_query($connect,$query); // check if mysql query successful if($result) { echo 'Data Inserted'; } else{ echo 'Data Not Inserted'; } mysqli_free_result($result); mysqli_close($connect); } ?> <!DOCTYPE html> <html> <head> <title> PHP INSERT DATA </title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form action="php_insert_data_in_mysql_database.php" method="post"> <input type="text" name="id" required placeholder="id"><br><br> <input type="text" name="name" required placeholder="name"><br><br> <input type="text" name="vin" required placeholder="vin" ><br><br> <input type="submit" name="insert" value="Add Data To Database"> </form> </body> </html>
Что я уже пробовал:
Я получаю ошибку, когда нажимаю кнопку отправить в своей форме.
<?php // php code to Insert data into mysql database from input text if(isset($_POST['insert'])) { $hostname = "localhost"; $username = "coleman"; $password = "Kkkholiday@33"; $databaseName = "test"; // get values form input text and number $id = $_POST['id']; $name = $_POST['name']; $vin = $_POST['vin']; // connect to mysql database using mysqli $connect = mysqli_connect($localhost, $coleman, $Kkkholiday@33, $test); // mysql query to insert data INSERT INTO `test`(`id`, `name`, `vin`) VALUES ([id],[name],[vin]) $result = mysqli_query($connect,$query); // check if mysql query successful if($result) { echo 'Data Inserted'; } else{ echo 'Data Not Inserted'; } mysqli_free_result($result); mysqli_close($connect); } ?> <!DOCTYPE html> <html> <head> <title> PHP INSERT DATA </title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form action="php_insert_data_in_mysql_database.php" method="post"> <input type="text" name="id" required placeholder="id"><br><br> <input type="text" name="name" required placeholder="name"><br><br> <input type="text" name="vin" required placeholder="vin" ><br><br> <input type="submit" name="insert" value="Add Data To Database"> </form> </body> </html>