<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/workshop/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("/$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


// submit form
if (@$_REQUEST['submit']) {

  // error checking
  $errorsAndAlerts = "";
  if (!@$_REQUEST['title'])    { $errorsAndAlerts .= "Please specify title!<br/>\n"; }
  if (!@$_REQUEST['email'])  { $errorsAndAlerts .= "Please specify content!<br/>\n"; }

  // turn off strict mysql error checking for: STRICT_ALL_TABLES
  mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)

  // add record
  if (!@$errorsAndAlerts) {
    mysql_query("INSERT INTO `{$TABLE_PREFIX}contact_requests` SET
                      title            = '".mysql_real_escape_string( $_REQUEST['title'] )."',
                      email          = '".mysql_real_escape_string( $_REQUEST['email'] )."',
                      category          = '".mysql_real_escape_string( $_REQUEST['category'] )."',
                      number            = '".mysql_real_escape_string( $_REQUEST['number'] )."',
                      content          = '".mysql_real_escape_string( $_REQUEST['content'] )."',

                      createdDate      = NOW(),
                      updatedDate      = NOW(),
                      createdByUserNum = '0',
                      updatedByUserNum = '0'")
    or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
    $recordNum = mysql_insert_id();

    // display thanks message and clear form
    $errorsAndAlerts = "Thanks, we will be in contact!";
  $csv = ''; 
  $csv .= implode(', ', array_map('_csvExport_escapeAsCSV', array_keys($_REQUEST))) . "\n"; 
  $csv .= implode(', ', array_map('_csvExport_escapeAsCSV', array_values($_REQUEST))) . "\n"; 
   
  sendMessage(array( 
    'from'    => "tim@forrest.id.au", 
    'to'      => "tim@toledoh.com.au", 
    'subject' => "Renovation Fix Contact", 
    'text'    => "Text message content", 
    'attachments' => array( 
      'form.csv'  => $csv 
    ) 
  ));
  }

}

?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/workshop/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records
  list($contactRecords, $contactMetaData) = getRecords(array(
    'tableName'   => 'contact',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $contactRecord = @$contactRecords[0]; // get first record


?>
<?php include ("_globalViewers.php") ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<title>TITLE GOES HERE</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />

<?php include ("_code.php") ?>
</head>
<body>
<?php include ("../_analytics.php") ?>
<div id="pagewidth" >
<?php include ("_navigation.php") ?>
<div id="wrapper" class="clearfix">
		<div id="twocols"> 
			<div id="maincol">
                <h1><?php echo $contactRecord['title'] ?></h1>
                <?php echo $contactRecord['content'] ?>
 <form method="post" action="">
<input type="hidden" name="submit" value="1" />
<input type="hidden" name="category" value="renovation" /></p>

<?php if (@$errorsAndAlerts): ?>
  <div class="alert"><br/>
    <?php echo $errorsAndAlerts; ?><br/><br/>
  </div>
<?php endif ?>


<p><span class="small">Name</span><br/>
<input class="formA" type="text" name="title" value="<?php echo htmlspecialchars(@$_REQUEST['title']) ?>" size="30" /></p>

<p><span class="small">Email</span><br/>
<input class="formA" type="text" name="email" value="<?php echo htmlspecialchars(@$_REQUEST['email']) ?>" size="30" /></p>

<p><span class="small">Contact number</span><br/>
<input class="formA" type="text" name="number" value="<?php echo htmlspecialchars(@$_REQUEST['number']) ?>" size="30" /></p>

<p><span class="small">Comments</span><br/>
<textarea class="formB" name="content" cols="30" rows="4"><?php echo htmlspecialchars(@$_REQUEST['content']) ?></textarea></p>

<input type="submit" name="add" value="Submit" class="button" />

</form>
               
          </div>
			<div id="rightcol">
            <?php include ("_rhsAds.php") ?>
            </div>
		</div> 
	<div id="leftcol">
		<?php include ("_sidenavigation.php") ?>
		<?php include ("_sideimagesLeft.php") ?>
    
    </div>
  </div>
<?php include ("_footer.php") ?>
</div>
</body>
</html>