To insert the data into the database we first need to establish the database connection. If you didn't know how to establish the database connection , you can visit this article ⇨ PHP database connection. You should develop your beginning skills using mysqli function as compared to mysql function.
For inserting the data into the database we just need the learn the query that how to write the query. We have to just pass the connection and query into the mysqli_query function.mysqli_query($connection , $query) Now we are going to insert the user's data into the below users table.
<?php $conn = mysqli_connect('localhost', 'root', '', 'myfirstdatabase'); mysqli_query($conn,"INSERT INTO users SET first_name='Ali',last_name='Khan',username='Alikhan2018', password='12345' "); ?>
<?php $conn = mysqli_connect('localhost', 'root', '', 'myfirstdatabase'); $first_name = 'Ali'; $last_name = 'khan'; $username= 'Alikhan2018'; $password = '12345'; mysqli_query($conn,"INSERT INTO users SET first_name='".$first_name."',last_name='".$last_name."', username='".$username."',password='".$password."' "); ?>