Insert data through ajax into mysql database

后端 未结 6 1193
灰色年华
灰色年华 2020-11-30 06:33

Newsletter:

\">
6条回答
  •  孤街浪徒
    2020-11-30 06:58

    I will tell you steps how you can insert data in ajax using PHP

    AJAX Code

    
    

    PHP Code:

    prepare("INSERT INTO 
    student(student_name,student_roll_no,student_class) 
    VALUES(:student_name, :student_roll_no,:student_class)");
    
     $stmt->bindparam(':student_name', $student_name);
     $stmt->bindparam(':student_roll_no', $student_roll_no);
     $stmt->bindparam(':student_class', $student_class);
     if($stmt->execute())
     {
      $res="Data Inserted Successfully:";
      echo json_encode($res);
      }
      else {
      $error="Not Inserted,Some Probelm occur.";
      echo json_encode($error);
      }
    
    
    
      ?>
    

    You can customize it according to your needs. you can also check complete steps of AJAX Insert Data PHP

提交回复
热议问题