connect_error) { die("Connection failed: " . $conn->connect_error); } // Insert values into table users $sql = "INSERT INTO users (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com')"; if ($conn->query($sql) === TRUE) { // Display ID of the last insert echo "New record created successfully. Last insert ID is: " . $conn->insert_id; } else { echo "Error: " . $sql . "This code inserts the values 'John', 'Doe', and 'john@example.com' into the table users, and displays the ID of the last insert. This example uses the MySQLi package library to connect to the database and perform the insertion. The insert_id method is also specific to the MySQLi package library.
" . $conn->error; } $conn->close(); ?>