Insert Data in MySQL DB using PHP
This is a simple post in php. In this post you will learn how to add data to the MySQL Database. Basically in this post, a form is used which accepts input from the user. A class DBClass is used for interactions with the database. Screenshot The Code The Config.php File <?php define("DB_NAME","sample");//Database Name define("DB_USER","root");//Database User define("DB_PASS","");//Database Password define("DB_HOST","localhost");//Database Host ?> The DBClass.php file <?php require_once 'config.php'; class DBClass { public function addData($table,$name,$phone,$email) { $con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME); $res=mysqli_query($con,"insert into $table values ('$name','$phone','$email')"); if($res) { echo '<script>alert("Data Succesfully inserted !")</script>'; } else { echo '...