An Example of Code To Insert Data To Database Using PHP MYSQL
An Example of Code To Insert Data To Database Using PHP MYSQL
```php
<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";
// Create connection
// Check connection
if ($conn->connect_error) {
$data2 = "john@example.com";
$sql = "INSERT INTO your_table_name (column1, column2, column3) VALUES ('$data1', '$data2',
'$data3')";
if ($conn->query($sql) === TRUE) {
} else {
$conn->close();
?>
```
This PHP code connects to a MySQL database and executes an INSERT query to add data to the specified
table. If the insertion is successful, it will display a success message; otherwise, it will display an error
message with details.