ASKER
<?php
/**
* Hello World! for WordPress
*
*
*/
add_action( 'wp_enqueue_scripts', 'ajax_signup_enqueue_scripts' );
function ajax_signup_enqueue_scripts() {
global $wp_query;
$page_id = $wp_query->post->ID;
$page_name = $wp_query->post->post_title;
$page_title = trim($page_name);
if(isset($page_title) === false || $page_title === '') {
// The title is empty
// Throw Fatal Error()
}
if(is_page()){ //Check if we are viewing sign up page
if($page_id === 37){
global $wpdb;
$fname = 'King '. $wpdb->prefix;
$lname = 'Kong!';
$table_name = "ps_contacts";
if ( $wpdb->insert(
$table_name,
array(
'fname' => $fname,
'lname' => $lname,
) != false )
// echo here fails, even when enclosed in {}
//echo "SUCCESS! SUCCESS! SUCCESS! SUCCESS! SUCCESS! SUCCESS! SUCCESS! SUCCESS! SUCCESS!";
);
}
}
}
?>
ASKER
error_log("Step 0", 0);
add_action( 'save_post', 'ajax_signup_insert_contact' );
function ajax_signup_insert_contact() {
error_log("Step 1", 0);
global $wp_query;
$page_id = $wp_query->post->ID;
$page_name = $wp_query->post->post_title;
Then, I check the database and found these records:ASKER
error_log("Step 0", 0);
add_action( 'save_post', 'ajax_signup_insert_contact' );
function ajax_signup_insert_contact() {
error_log( "Step 1", 0);
global $wp_query;
$page_id = $wp_query->post->ID;
$page_name = $wp_query->post->post_title;
error_log( "Step 2", 0);
if(is_page()){ //Check if we are viewing sign up page
error_log( "Step 3", 0);
if($page_id === 37){
error_log("Step 4", 0);
global $wpdb;
$fname = 'C';
$lname = 'D';
$table_name = "ps_contacts";
if ( $wpdb->insert(
$table_name,
array(
'fname' => $fname,
'lname' => $lname,
)
) == false)
{
error_log( "FAILED", 0);
}
}
}
ASKER
add_action( 'save_post', 'ajax_signup_insert_contact' );
function ajax_signup_insert_contact() {
error_log( "Step 1", 0);
global $wp_query;
$page_id = $wp_query->post->ID;
$page_name = $wp_query->post->post_title;
/*if(isset($page_title) === false || $page_title === '') {
// The title is empty
// Throw Fatal Error()
}*/
error_log( "Step 2", 0);
if(is_page()){ //Check if we are viewing sign up page
error_log( "Step 3", 0);
if($page_id === 37){
error_log("Step 4", 0);
global $wpdb;
$fname = 'C';
$lname = 'D';
$table_name = "ps_contacts";
if ( $wpdb->insert(
$table_name,
array(
'fname' => $fname,
'lname' => $lname,
)
) == false)
{
error_log( "FAILED", 0);
}
}
}
}
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
ASKER
File: wp-includes/wp-db.php