Include File appearing at top of page

So someone else wrote the code for this webpage. I am just adding a contact form for a client, however, I seem to be having issues inserting an include statement. When I include the file, it appears on the website as the very first thing on the page no matter where I put it in the file. I placed the three key files here. 1) The website where the file is included, 2) The included contact form file, 3) the working part of the contact form.

I feel like there is something really simple I’m missing here. Any help would be appreciated! Thanks in advance.

[php]

<?php $menu = $_GET["menu"]; //if menu statement removed for brevity }elseif( $menu == 'contact' ){ $temp_title = "Contact Us "; $temp_background = 'layer_other'; $tc05 = "class=sel_page"; $temp_content = "

Contact Us

Need help, why wait? Contact us today!
Phone: 770-837-8137
Email:


Atlanta Psychotherapy Solutions, LLC operates the following specialty websites highlighting mental health conditions and our treatments to benefit you or a loved one. Please view our websites for further information:

    list

Call us at (770)837-8137 (call 911 in case of emergency).
If you prefer email, feel free to email us at ".hide_email("[email protected]")."

We are located at 2150 Peachford Rd, Suite A
Atlanta (Dunwoody), GA 30338

Map

"; $contact_form = ''.include ("contactform.php").''; $map_script = 'map script goes here'; $map_bodyload = 'onload="load()" onunload="GUnload()"'; }else{ $temp_title = "Deeper Life Solutions & Atlanta DBT Treament: Counseling Psychotherapy for Anxiety, Depression, Addictions in Atlanta "; $temp_background = 'layer_home'; $tc01 = "class=sel_page"; $temp_content = "main page"

What We Do

We provide psychiatric, psychotherapy, and counseling services for the Greater Metropolitan Atlanta area.

We provide brief therapy approaches, long-term counseling, psychiatric medication management, in-patient hospital care, intensive outpatient programs.

We provide referrals to local psychiatrists, behavioral health hospitals, rehab programs, half-way houses, and therapists.

We are a group of real people who are professionals that care about your emotional and mental wellness. We work with you to resolve complex issues that impact your daily life.

We provide lots of different services, so please take your time and look through this website or call us at (770) 837-8137 or email us at ".hide_email("[email protected]").".

Our services include

    list

We all experience difficulties or challenges at different times in our lives. Often, we can handle things on our own or with the help of some good friends. But, there are times when professional assistance may be needed. Counseling and psychotherapy can help you through the difficult times of your life.

We are here to assist you with your mental health needs. Our board certified psychiatrists and licensed psychotherapists have excellent skills along with years of personal and clinical experience to provide you with professional mental health care within the Metro Atlanta area.

We provide treatment for

    list
"; } $temp_top_menu = "
"; ?> <?= $temp_title; ?> <?= $map_script; ?> >
>
<?= $temp_top_menu; ?>
<?= $temp_content; ?>

Copyright © 2009-2011. All rights reserved. Developed by John Y. Kim.

Alpharetta, Atlanta, Symrna, Johns Creek, Buckhead, Dunwoody, Lawrenceville, Duluth, Marietta, Woodstock, Acworth, Metro Atlanta, Brookhaven, Decatur, Roswell, Sandy Springs, North Georgia, Ellijay

Optimization by Gaius J. Augustus.

<?php function left_menu01($opt){ //left menu

if( $opt == 1 ){ $mc01 = “class=menu_choice”; }
etc

$temp_left_menu = "

";

return $temp_left_menu;
}

function left_menu02($opt){
//left menu

if( $opt == 1 ){ $mc01 = “class=menu_choice”; }
if( $opt == 2 ){ $mc02 = “class=menu_choice”; }

$temp_left_menu = "

";

return $temp_left_menu;
}

function left_menu03($opt){
//left menu

if( $opt == 1 ){ $mc01 = “class=menu_choice”; }
if( $opt == 2 ){ $mc02 = “class=menu_choice”; }
if( $opt == 3 ){ $mc03 = “class=menu_choice”; }
if( $opt == 4 ){ $mc04 = “class=menu_choice”; }
if( $opt == 5 ){ $mc05 = “class=menu_choice”; }
if( $opt == 6 ){ $mc06 = “class=menu_choice”; }

$temp_left_menu = "

";

return $temp_left_menu;
}

?>
[/php]

Here is the code for the form, created using Contacular:
[php]<?php include_once ‘contacular.php’;

$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 Please give a brief explanation. ',
‘mandatorytextarea’, 100, 200);
//$form->addField(‘picture’, ‘Add a picture’, ‘file’);
//$form->addField(‘response’, ‘Want a response?’, ‘checkbox’);

$form->addRecipient(‘myemail’); // Add a recipient

if ($form->processResponse()) // If we processed a response from the form…
{
echo 'Thanks for contacting us!

'; // display a ‘thanks’ message
}
else // otherwise
{
echo $form->getErrors(); // show any validation errors
echo $form->getCode(); // and output the form code.
}
?>[/php]

And here is the include_once file mentioned in the contact form file:
[php]<?php
// *** Class Declaration ***

class ContacularForm
{
// *** Member Variable Declaration ***

private $attribution = true;
private $advancedValidation = true;
private $fields = array();
private $recipients = array();
private $seperator;
private $errors = array();
private $recaptchaPublicKey = null;
private $recaptchaPrivateKey = null;
private $disallowedTypes = array("exe", "dll", "vbs", "js", "bat", "bin", "php", "phps", "asp", "aspx", "js", "scr");	
	
// *** Public Member Functions ***

/* 
Function: Constructor
Purpose: Called upon instantiated to perform initial setup of the form fields if a specific '$type' is passed.
Arguments:
	$type - Determines the type of form to generate
	$width - Overrides default width of form fields (in pixels) - useful for making form fit (in sidebars for example)
*/	
public function __construct($type=false, $width=null)
{
	if ($type) $this->setup($type, $width);
}

/* 
Function: addRecipient
Purpose: Used to add a new e-mail address to the list of e-mail recipients associated with this form
Arguments:
	$recipient - E-mail address recipient to associate with this form
*/
public function addRecipient($recipient)
{
	$this->recipients[] = $recipient;
}

/* 
Function: setSeperator
Purpose: Used to set the character or string which seperates the form field names from the data entry elements
Arguments:
	$seperator - Character or string used to seperate form field names from data entry elements (e.g. ':', ' -' or ':-')
*/
public function setSeperator($seperator)
{
	$this->seperator = $seperator;
}

/* 
Function: setAttribution
Purpose: Sets whether or not the attribution text, 'Powered by Contacular', is displayed on generated forms
Recommendation: Leaving this text displayed gives credit to the original author, and helps promote Contacular
Arguments:
	$attribution - Boolean used to determine whether or not the 'Powered by Contacular' text is displayed
*/
public function setAttribution($attribution = true)
{
	$this->attribution = $attribution;
}

/* 
Function: setDisallowedTypes
Purpose: Allows you to override thhe default array of disallowed file types for uploaded files
Arguments:
	$disallowedTypes - Array of file extensions which are disallowed for the upload of files.
*/
public function setDisallowedTypes($disallowedTypes)
{
	$this->disallowedTypes = $disallowedTypes;
}

/* 
Function: setRecaptchaPublicKey
Purpose: Sets the Recaptcha public key obtained from recaptcha.net and enables Recaptcha checking
Arguments:
	$recaptchaPublicKey - Recaptcha public key obtained from recaptcha.net
*/
public function setRecaptchaPublicKey($recaptchaPublicKey)
{
	$this->recaptchaPublicKey = $recaptchaPublicKey;
}

/* 
Function: setRecaptchaPrivateKey
Purpose: Sets the Recaptcha public key obtained from recaptcha.net and enables Recaptcha checking
Arguments:
	$recaptchaPublicKey - Recaptcha public key obtained from recaptcha.net
*/
public function setrecaptchaPrivateKey($recaptchaPrivateKey)
{
	$this->recaptchaPrivateKey = $recaptchaPrivateKey;
}

/* 
Function: setAdvancedValidation
Purpose: Sets whether or not advanced validation checking is performed (such as DNS A record checking on e-mail address validation)
Recommendation: Enabled by default (recommended) to ensure maximum validation, but could potentially cause false positives.
Arguments:
	$advancedValidation - Boolean used to determine whether or not advanced validation techniques are used
*/
public function setAdvancedValidation($advancedValidation = true)
{
	$this->advancedValidation = $advancedValidation;
}

/* 
Function: getCode
Purpose: Generate the defined form HTML code and return it for output or other use
Returns: String - Generated HTML code for form
Arguments:
	None
*/
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;
}

//Took out most of the Process stuff because post was too long
?>[/php]

I’m pretty sure the problem is in the first code I put here, the main website. I’ve inserted a test function at the bottom of the page

[php] function test(){
echo “this is a test”;
}[/php]

and I’ve placed the test() tag in the $temp_content where I want it. Using this, the function STILL appears at the top of the page, instead of in the section I put it. Here’s the code. I hope someone can give me some guidance…

[php]}elseif( $menu == ‘contact’ ){
$temp_title = "Contact Us - Deeper Life Solutions & Atlanta DBT Treament: Counseling Psychotherapy for Anxiety, Depression, Addictions in Atlanta ";
$temp_background = ‘layer_other’;
$tc05 = “class=sel_page”;

$temp_content = "
<div id=content>

	<div id=contentleft>
    <div id=box01>
  	</div>
  </div>

	<div id=contentright>
    <div id=box02>

Contact Us

Need help, why wait? Contact us today!
Phone: 770-837-8137
Email: ".hide_email("[email protected]")."

Or Fill Out Our Contact Form


[b]".test()."[/b]

Atlanta Psychotherapy Solutions, LLC operates the following specialty websites highlighting mental health conditions and our treatments to benefit you or a loved one. Please view our websites for further information:

    list

Call us at (770)837-8137 (call 911 in case of emergency).
If you prefer email, feel free to email us at ".hide_email("email")."

We are located at 2150 Peachford Rd, Suite A
Atlanta (Dunwoody), GA 30338

Map

<img title='Deeper Life Solutions: We care about your mental and emotional wellness!'src=spacer.gif height=200px>

  	</div>
	</div>

</div>
";



$map_script = '
<script src="http://maps.google.com/maps?file=api&v=2&key='.$google_key.'" type="text/javascript"></script>
<script type="text/javascript">
var map;
var marker = new Array(1); 
var markerCount = 0;

function addMarker(overlay, latlng) {
	var icon = new GIcon();
	icon.image = "redpin.png";
	icon.shadow = "pin_shadow.png";
	icon.iconSize = new GSize(20, 20);
	icon.shadowSize = new GSize(30, 20);
	icon.iconAnchor = new GPoint(10, 30);
	icon.infoWindowAnchor = new GPoint(10, 30);    
	
	marker[markerCount] = new GMarker(latlng, icon);
    map.addOverlay(marker[markerCount]);
    markerCount = markerCount+1;
}

function load() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(33.923350,-84.303370), 14);
			map.addControl(new GSmallMapControl()); 
			map.addControl(new GMapTypeControl());
  	addMarker(map, new GLatLng(33.923350,-84.303370))
  }
}
</script>';

$map_bodyload = 'onload="load()" onunload="GUnload()"';

}else{
$temp_title = "Deeper Life Solutions & Atlanta DBT Treament: Counseling Psychotherapy for Anxiety, Depression, Addictions in Atlanta ";
$temp_background = ‘layer_home’;
$tc01 = “class=sel_page”;

$temp_content = "default content

";

?>

<?= $temp_title; ?> <?= $map_script; ?> >
>
<?= $temp_top_menu; ?>
<?= $temp_content; ?>
<?php function left_menu01($opt){ //left menu

if( $opt == 1 ){ $mc01 = “class=menu_choice”; }
if( $opt == 2 ){ $mc02 = “class=menu_choice”; }
if( $opt == 3 ){ $mc03 = “class=menu_choice”; }
if( $opt == 4 ){ $mc04 = “class=menu_choice”; }
if( $opt == 5 ){ $mc05 = “class=menu_choice”; }
if( $opt == 6 ){ $mc06 = “class=menu_choice”; }
if( $opt == 7 ){ $mc07 = “class=menu_choice”; }
if( $opt == 8 ){ $mc08 = “class=menu_choice”; }
if( $opt == 9 ){ $mc09 = “class=menu_choice”; }
if( $opt == 10 ){ $mc10 = “class=menu_choice”; }
if( $opt == 11 ){ $mc11 = “class=menu_choice”; }
if( $opt == 12 ){ $mc12 = “class=menu_choice”; }
if( $opt == 13 ){ $mc13 = “class=menu_choice”; }
if( $opt == 14 ){ $mc14 = “class=menu_choice”; }
if( $opt == 15 ){ $mc15 = “class=menu_choice”; }

$temp_left_menu = "

    list
";

return $temp_left_menu;
}

function left_menu02($opt){
//left menu

if( $opt == 1 ){ $mc01 = “class=menu_choice”; }
if( $opt == 2 ){ $mc02 = “class=menu_choice”; }

$temp_left_menu = "

";

return $temp_left_menu;
}

function left_menu03($opt){
//left menu

if( $opt == 1 ){ $mc01 = “class=menu_choice”; }
if( $opt == 2 ){ $mc02 = “class=menu_choice”; }
if( $opt == 3 ){ $mc03 = “class=menu_choice”; }
if( $opt == 4 ){ $mc04 = “class=menu_choice”; }
if( $opt == 5 ){ $mc05 = “class=menu_choice”; }
if( $opt == 6 ){ $mc06 = “class=menu_choice”; }

$temp_left_menu = "

";

return $temp_left_menu;
}

function hide_email($email, $linkword=’’) {
$character_set = ‘±.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz’;
$key = str_shuffle($character_set); $cipher_text = ‘’; $id = ‘e’.rand(1,999999999);
for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
$script = ‘var a="’.$key.’";var b=a.split("").sort().join("");var c="’.$cipher_text.’";var d="";’;
$script.= ‘for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));’;
if( $linkword != ‘’ ){
$script.= ‘document.getElementById("’.$id.’").innerHTML="<a href=\“mailto:”+d+"\" rel=nofollow>"+"’.$linkword.’"+""’;
}else{
$script.= ‘document.getElementById("’.$id.’").innerHTML="<a href=\“mailto:”+d+"\" rel=nofollow>"+d+""’;
}
$script = “eval(”".str_replace(array("\",’"’),array("\\",’"’), $script)."")";
$script = ‘’;
return ‘[javascript protected email address]’.$script;

}

function test(){
echo “this is a test”;
}
[/php]

It’s because you are declaring the include in a variable and then as far as I can see (though i prob missed it) not calling that variable. This is unnecessary. Simply use the include(); tag wherever you want the form to appear without calling it in a variable.

The big problem here is that I need to end that line (include (‘contactform.php’);), but can’t because it’s within a string, because of the way the coding was done by the original programmer. If I end it here, the rest of the text will not show up, unless you can show me how to do this (I could very well be doing this wrong). The only way I could think of to do this was to put the form data into a string ( $contact_form ) or function ( contactform() ) and call it inside the $temp_content string.

I’ve tried these options, but the contact form won’t show up with the text.

So if it’s supposed to be “Fill out our content form. Name ________ Phone ________ SUBMIT Feel free to call us!” Instead it just says “Fill out our content form. Feel free to call us”

I appreciate the help and hope you can see something simple I’m missing! Thank you!

  1. The code where I want the item to be

[php]$temp_content = "

	<div id=contentright>
    <div id=box02>

Contact Us

Need help, why wait? Contact us today!
Phone: 770-837-8137
Email: ".hide_email("email")."

Or Fill Out Our Contact Form


".contactform()."

We operates the following specialty websites highlighting mental health conditions and our treatments to benefit you or a loved one. Please view our websites for further information:

    list
</div>
";
<?= $temp_content ?>[/php]
  1. The contact form
    [php]function contactform() {
    include_once ‘contacular.php’;

/* return "


<img title='Deeper Life Solutions: We care about your mental and emotional wellness!'src=image/logo.png>


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.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! '; // display a ‘thanks’ message
}
else // otherwise
{
return $form->getErrors(); // show any validation errors
return $form->getCode(); // and output the form code.
}
} [/php]

  1. The contacular.php file
    This is the same as the file I put above.
    [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;
    

    }[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service