PHP Tutorial: How to insert data into mysql backend using php

INTRODUCTION

PHP is the most popular server side scripting language which is widely used across the world. PHP coding is mainly used to deal with server operations such as saving data onto server, extracting data from server and other server side operations. This video does not contain the first lesson of PHP, it contains the lesson where i have explained how to save data onto backend mysql using PHP. If you want to learn full PHP, enroll my course “Complete Web Development Online Course” by clicking here

How to insert records into MySql using PHP step by step

In the above video you will find step by step procedure to insert records from html file into back end MySql using server side scripting language PHP. To learn more about PHP or any other web designing languages you can enroll for the courses in ENROLL-COURSE tab. A brief introduction about MySql function of PHP used in this lesson:
  1. mysql_connect() : This function of PHP is the main function used to connect your front-end to MySql back end. There are three parameters for this function namely: a) server-name b) username c) password For example if you want to connect to localhost then the format is:
    mysqli_connect(“localhost”,”root”,””)
    Default Localhost Credentials :
    1. Server Name: “localhost”
    2. User Name: “root”
    3. Password: null
  2. mysqli_select_db() : This function is used to connect to particular database in you server. After connecting front end to database, the next step is to connect to desired database because a back-end (MySql) may have multiple databases in it. Hence using mysqli_select_db() function you specify which database should be connected to your connection variable. This function has two parameters namely a) connection variable b) database name
    Exmaple: mysqli_select_db($conn,”databasename”)
  3. mysqli_query() : This function is used to run the query of MySql such as inserting a new record, selecting a required record etc. This function has two parameters a) connection variable b) query string
    Example: mysqli_query($conn, $sql) or die(mysqli_error())

Leave a Reply