Okay, I understand the difference between return and echo now. Thank you!
I'm now able to put the test function in and have the text go into the correct place.
So, moving on to the next step, I'm trying to have my original code (which was in my first post) appear in the correct place. This code is the Contacular dynamic form. Here is the code I've put in a function:
It is the following function:
function contactform() {
include_once 'contacular.php';
return "<div id=header><div id=box03><a href=./ title='Deeper Life Therapy'>
<img title='Deeper Life Solutions: We care about your mental and emotional wellness!'src=image/logo.png></a></div></div>
<br> Please Fill in the Contact Form below and we will get back to you as soon as possible.";
$form = new ContacularForm('custom'); // Create a custom Contacular Form
$form->setAttribution(false);
$form->addField('from_name', 'First Name Last Initial (e.g., John D)', 'mandatorytext', null, 200);
$form->addField('age', 'Private Cell Phone Number', 'mandatorytext', null, 200);
$form->addField('from_email', 'E-mail', 'email', null, 200);
$form->addField('gender', 'Best Time to Call', 'mandatory text', null, 200);
$form->addField('bestway', 'Best Way to Reach You', 'select', null, 70, array('Phone', 'Email'));
$form->addField('enquiry', 'Reason for Contacting Us
(e.g., Depression, Relationship Problems, Alcohol or Drug Abuse, etc.) Please give a brief explanation. ',
'mandatorytextarea', 100, 200);
//$form->addField('picture', 'Add a picture', 'file');
//$form->addField('response', 'Want a response?', 'checkbox');
$form->addRecipient('email'); // Add a recipient
if ($form->processResponse()) // If we processed a response from the form...
{
echo 'Thanks for contacting us! <br>
<a href=\'http://www.deeperlifetherapy.com\'>Click here to return to Deeper Life Solutions</a>'; // display a 'thanks' message
}
else // otherwise
{
echo $form->getErrors(); // show any validation errors
echo $form->getCode(); // and output the form code.
}
}
And here is the HTML generator for the form, that is included in the previous function, contacular.php:
public function getCode()
{
// Check sanity of ContacularForm object
if ($sanity = $this->sanityCheck()) return $sanity;
// Generate HTML code
$url = $this->getURL();
if ($this->attribution)
{
$code = "\n<!-- Contacular Form Start (http://contacular.co.uk/) -->\n";
}
$code .= "<form method=\"post\" action=\"".$url."\" name=\"contacularform\" enctype=\"multipart/form-data\">";
$code .= "<table>";
foreach ($this->fields as $field)
{
$code .= "<tr>";
$code .= "<td width='250'><label for=\"".$field['name']."\">".$field['label'].$this->seperator." </label></td>";
$code .= "<td>";
$code .= $this->getFormFieldText($field);
$code .= "</td>";
$code .= "</tr>";
}
if ($this->recaptchaPublicKey && $this->recaptchaPrivateKey)
{
require_once('recaptchalib.php');
$code .= "<tr><td></td><td>";
$code .= recaptcha_get_html($this->recaptchaPublicKey);
$code .="</td></tr>";
}
$code .= "<tr><td></td><td><input style=\"font-family: inherit;\" type=\"submit\" name=\"contacularform_submit\" value=\"Send\" /> ".$this->getAttributionText()."</td></tr>";
$code .= "</table>";
$code .= "</form>";
if ($this->attribution)
{
$code .= "\n<!-- Contacular Form End -->\n";
}
return $code;
}
There is more to this code that I can give if needed, that creates the form. Again, thank you. Sorry I'm slow, but my client is allowing me to work for him understanding I'm still learning.
Currently, the returned text (the logo and the Please fill in the contact form below text) appears correctly, but none of the form shows up.