<?php



// ============== Send a record to the database ==============
error_reporting(E_ALL);
ini_set('display_errors', 1);

# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbhost = 'localhost';
$dbuser = 'root';
//$dbpass = 'VsQ$vxK3'; //staging
$dbpass = 'nz2@z5Wv'; //production
$dbname = 'feedback';

$conn = new mysqli($dbhost, $dbuser, $dbpass) or die("Unable to connect to '$dbhost'");
mysqli_select_db($conn, $dbname) or die("Could not open the db '$dbname'");
// $test_query = "SHOW TABLES FROM $dbname";
// $result = mysqli_query($conn, $test_query);
// $tblCnt = 0;
// while($tbl = mysqli_fetch_array($result)) {
//   $tblCnt++;
//   echo $tbl[0]."<br />\n";
// }
// if (!$tblCnt) {
//   echo "There are no tables<br />\n";
// } else {
//   echo "There are $tblCnt tables<br />\n";
// }


$url        = $conn->real_escape_string($_POST['url']);
$helpful    = $conn->real_escape_string($_POST['helpful']);
$comment    = $conn->real_escape_string($_POST['comment']);
$query      = "INSERT into tb_wth (url,helpful,comment) VALUES('" . $url . "','" . $helpful . "','" . $comment . "')";
$success    = $conn->query($query);

if (!$success) {
    die("Couldn't enter data: ". $conn->error);

}

// ============== End Send a record to the database ==============


//
// // ============== Send Email ==============
// // Comment out this entire section if you do not wish to send an email upon form submission
//
// if ($app == 'Arta Lending') {
//   $to = 'artalendingsup@wolterskluwer.com';
// } elseif ($app == 'Cash Suite') {
//   $to = 'CASHsupport@wolterskluwer.com';
// } elseif ($app == 'ComplianceOne Deposit') {
//   $to = 'ComplianceOnedeposit@wolterskluwer.com';
// } elseif ($app == 'ComplianceOne Lending') {
//   $to = 'ComplianceOneSupport@wolterskluwer.com';
// } elseif ($app == 'ComplianceOne Interfaces') {
//   $to = 'ComplianceOneManagerSupport@wolterskluwer.com';
// } elseif ($app == 'ComplianceOne manager') {
//   $to = 'ComplianceOneManagerSupport@wolterskluwer.com';
// } elseif ($app == 'ComplianceOne mortgage') {
//   $to = 'ComplianceOneMortgageSupport@wolterskluwer.com';
// } elseif ($app == 'Document Generation Services') {
//   $to = 'ExpereIESupport@wolterskluwer.com';
// } elseif ($app == 'Expere Document Services') {
//   $to = 'ExpereIESupport@wolterskluwer.com';
// } elseif ($app == 'Medici') {
//   $to = 'medicisupport@wolterskluwer.com';
// } elseif ($app == 'PubAssist FTP') {
//   $to = 'kelly.mankenberg@wolterskluwer.com';
// } elseif ($app == 'Requirements Editor') {
//   $to = 'ExpereIESupport@wolterskluwer.com';
// } elseif ($app == 'TSoftPlus') {
//   $to = 'tsoftsup@wolterskluwer.com';
// } elseif ($app == 'Settlement Services') {
//   $to = 'kelly.mankenberg@wolterskluwer.com';
// } else {
//   $to = 'kelly.mankenberg@wolterskluwer.com';
// }
//
// // $to = 'kelly.mankenberg@wolterskluwer.com';
//
// $subject = "Online Documentation Feedback";
// $email = $_POST['email'];
// $headers = "From: $email";
//
// $email_message .= "Online Documentation Feedback\r\n" ;
// $email_message .= "The following feedback was received using the Feedback form within the InfoDev online documentation.\r\n\r\n" ;
//
// $email_message .= "Date and Time: " . date('m/d/Y, H:i:s') . "\r\n";
// $email_message .= "Page URL: " . strip_tags($_POST['url']) . "\r\n\r\n";
//
// $email_message .= "Name: " . strip_tags($_POST['full_name']) . "\r\n";
// $email_message .= "Company: " . strip_tags($_POST['company']) . "\r\n";
// $email_message .= "Client ID: " . strip_tags($_POST['clientid']) . "\r\n";
// $email_message .= "Email: " . strip_tags($_POST['email']) . "\r\n";
// // $email_message .= "<tr>
// 					  // <td class='col1'>Contact me? </td>
// 					  // <td>" . $Contact . "</td>
// 					// </tr>";
// $email_message .= "Contact Number: " . strip_tags($_POST['telephone']) . "\r\n";
// $email_message .= "Product: " . strip_tags($_POST['app']) . "\r\n";
// $email_message .= "Reason: " . strip_tags($_POST['reason']) . "\r\n";
// $email_message .= "Comment: " . strip_tags($_POST['comments']) . "\r\n";
//
//
// $sent = mail($to, $subject, $email_message, $headers);
//
// if($sent)
// //{print "Your mail was sent successfully"; }
// 	{print "";}
//
// else
// //{print "We encountered an error sending your mail"; }
// echo "<div style='font-family:Calibri; margin:0 auto; margin-top:50px; width: 500px'>
// 		<p>We have encountered an error sending an email. However, your submission has been stored in our database.</p>
// 		</div>";
//
// // ============== End of Send Email ==============

?>


