Hey
So I am currently developing my first wordpress Plugin and i am stumped.
i need to insert some form data posted from the about page to a custom hanlderform.php in my plugins folder. It won't run the function that actually inserts the data into the table. i assume this is because i am running it outside the WordPress framework. So my question is this how do I get it inside the framework of WordPress what do I hook onto with my add_action() function?
Thanks guys
Nathan
At current i either have no error and it does nothing or if i try adding an add_action() function it states it is undifined.
handlerform.php
[code]
<?php
// values sent from form
$contestname=$_POST['contestname'];
$emailaddr=$_POST['emailaddr'];
$floa=$_POST['floa'];
$postcode=$_POST['postalcode'];
$courseone=$_POST['coi1'];
$coursetwo=$_POST['coi2'];
//validate form data
if ($contestname == "") {
echo "You have not entered your Name!";
}
elseif ($emailaddr == "") {
echo "You have not entered an Email Address!";
}
elseif ($floa == "") {
echo "You have not entered your First line of address!";
}
elseif ($postcode == "") {
echo "You have not entered your Postal Code!";
}
else
{
//eccho form data (FOR TESTING)
echo "$contestname<br />";
echo "$emailaddr<br />";
echo "$floa<br />";
echo "$postcode<br />";
echo "$courseone<br />";
echo "$coursetwo<br /><br />";
}
//store form data into an array
$form_details = array("$contestname", "$emailaddr", "$floa", "$postcode", "$courseone", "$coursetwo");
//print array (FOR TESTING)
print_r($form_details);
function insert_data() {
global $wpdb;
echo 'Hello 1';//testing
/*$wpdb->insert( '$table_name', array( 'column1' => 'value1', 'column2' => 123 ), array( '%s', '%d' ) )*/
$table_name = $wpdb->prefix . "data_captcha";
$wpdb->query( $wpdb->prepare( "
INSERT INTO wp_data_captcha
( name, email, floa, postcode, course1, course2 )
VALUES ( %s, %s, %s, %s, %s, %s )",
$contestname, $emailaddr, $floa, $postcode, $courseone, $coursetwo ) );
echo 'Hello 2';//testing
$wpdb->show_errors();
$wpdb->hide_errors();
}
?>
[/code]