I have want to save field value of Contact Form 7 plugin in database using this code:
add_action('wpcf7_before_send_mail', my_conversion($cf7));
function my_conversion($cf7)
{
$name = $cf7->posted_data["your-name"];
$email = $cf7->posted_data["your-email"];
$Work = $cf7->posted_data["tel-Work"];
$homenumber = $cf7->posted_data["homenumber"];
$mobilenumber = $cf7->posted_data["mobilenumber"];
mysql_query("INSERT INTO `hello` (`Your Name`, `Work`, `Home`, `Mobile No`, `Email`) VALUES ('$name',$Work,$homenumber,$mobilenumber,$email)");
}
but its not working, here’s the error:
"`$cf7->posted_data["...."]`;" can not fetch values.
This is wrong:
add_action('wpcf7_before_send_mail', my_conversion($cf7));
It should be:
To know what values are available in your
$cf7
object, addvar_dump( $cf7 );
at the beginning of yourmy_conversion
function.DO NOT USE
mysql_query
! Use theWPDB Class
instead.And lastly, there’s the Flamingo Plugin which saves your form automatically upon submission.
yous should try using wp prepared query instead of direct query