I'm simply trying to process data from an html form into my wordpress database through php. I've tried multiple times to get the data inserted but have had no luck.
The setup is as follows: Database name: seanmcve_AssociationNation Table: association The row I want data entered in: association_first_name
I've setup a page template called form_processing_template.php.
<?php
/*
Template Name: form processing template
*/
?>
<form action="" method="post">
<h4><strong>What is the legal name of your association?</strong></h4>
<input name="legalName" type="text" placeholder="Association Name" />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
If($_POST['submit']) {
// run validation if you're not doing it in js
$legalname=$_POST['legalName'];
echo $legalname;
$wpdb->insert('association',
array(
'association_first_name' => '$legalname'
),
array(
'$s',
)
);
}
?>
<?php x_get_view( x_get_stack(), 'wp', 'page' ); ?>
I'm echoing the variable just to make sure it's correct and working (which is working) I've been referencing the wpdb class reference page and still have had no luck. Can anyone point me in the right direction?