wordpress SAVEQUERIES code example
Example 1: debug wordpress
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Example 2: wordpress debug config
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define( 'SCRIPT_DEBUG', true );
Example 3: wordpress query to save in database
<?php
if (!empty($_POST)) {
global $wpdb;
$table = 'contact_form';
$data = array(
'names' => $_POST['yourname'],
'emails' => $_POST['customer_email'],
'gender' => $_POST['customer_gender'],
'age' => $_POST['customer_age']
);
$success=$wpdb->insert( $table, $data );
if($success){
echo 'data has been save' ;
}
} else {
echo "data not save";
}
?>
<div class="container">
<div class="row ">
<div class="col-md-12 pb-5">
<form method="post">
Your name:<input type="text" name="yourname" id="yourname">
Your Email:<input type="text" id="customer_email" name="customer_email"/><br>
Gender:<input type="radio" name="customer_gender" value="male">Male
<input type="radio" name="customer_gender" value="female">Female<br>
Your Age:<input type="text" name="customer_age" id="customer_age"><br>
<input type="submit" name="submit" value="Submit">
</form>
</div>
</div>
</div>