In this tutorial i will explain you how to create store procedure in mysql and insert data in table

Create Store Procedure Code

CREATE PROCEDURE insertRecord(studentName varchar(255),class varchar(255),address varchar(255))
BEGIN
INSERT INTO tbl_student(name,class,address) VALUES(studentName,class,address);
END


Insert Data into tabel using store procedure in php

if(isset($_POST['action'])) {
    $studentname=$_POST['studentname'];
    $class=$_POST['class'];
    $address=$_POST['address'];
    $sql ="CALL insertRecord('$studentname','$class','$address')";
   //this line call store procedure
   if(mysql_query($sql) or die(mysql_error())){
       header('Location:index.php?m=1');
    }else{
    header('Location:index.php?m=0');
    }
}


 

Download demo

If love this tutorial Please Like this page