How to insert data using wpdb

Md Riyazuddin Verified
You can insert your data via prepare method because prepare help to secure from SQL injection .
global $wpdb;
$tablename = $wpdb->prefix . "submitted_form";
$name     = "Kumkum"; //string value use: %s
$phone    = "3456734567"; //numeric value use: %d
$sql = $wpdb->prepare("INSERT INTO `$tablename` (`name , `phone`) values (%s, %d)", $name, $phone);
$wpdb->query($sql);
And this help to secure insert data in  WordPress .

References and Credits

Comments

Leave a Comment