Seasoned dev, but new to wordpress development - becoming a fan very quickly.
I'm knocking up my first wordpress plugin (custom contact form for client, none of the plugins can do the jazz I need).
I can't work out how to submit the form and grab the data. Heres what I've got so far:
function cafesignup_function() {
$x = parse_url($_SERVER['HTTP_REFERER']);
$pageRef = basename($x['path']);
if(isset($_POST['submit']))
{
$name = $_POST['companyName'];
$demolp_output = $name;
} else {
$greeetingText = "<h1>" . getTitle($pageRef) . " Quote Form</h1>";
$demolp_output = "<div class='mtool ccupform'></div> <div class='greeting-text'><p>" . $greeetingText . "</p></div><div class='maintext'> <div class='errortext'> </div><small>Fields with a * are required fields.</small>";
$demolp_output .= "<form name='quoteForm' id='quoteForm' method='post' action='/request-a-quote' >";
$demolp_output .= "<p>Contact Name*<br />";
$demolp_output .= "<input type='text' class='validate bjp-contact' name='companyName' id='cafeCompanyName' value='' size='40' class=''></p>";
$demolp_output .= "<p>Business name if Applicable<br />";
$demolp_output .= "<input type='text' class='validate bjp-contact' id='cafeFirstname' value='' size='40' class=''></p>";
$demolp_output .= "<p>Telephone including STD*<br />";
$demolp_output .= "<input type='text' class='validate bjp-contact' id='cafeSurname' value='' size='40' class=''></p>";
$demolp_output .= "<p>Email Address*<br />";
$demolp_output .= "<input type='text' class='validate vemail bjp-contact' id='cafeEmailAddress' value='' size='40' class=''></p>";
$demolp_output .= "<p> <div class='pull-right'><span onclick='clear();' id='cafeAdd2' class='btnN'>Clear</span>  <span onclick='addUser();' id='cafeAdd2' class='btnY'>Submit</span></center></p>";
$demolp_output .= "</div>";
$demolp_output .= "</form>";
}
return $demolp_output;
}
When I submit that (using jquery for the submit, as below) it fires the submit, but it shows the fro again (also I can't work out what to put as the action on the form to reuse the plugin elsewhere).
function addUser(){
var emailvalidates = true;
jQuery( ".validate" ).each(function() {
if(jQuery(this).val() == ""){
validates = false;
alert("missing fields");
} else {
$('#quoteForm').submit();
}
});
}