Hello
I am trying to run an exit survey when people leave my website. I really have no Idea how to got about it, so I have been piecing together PHP code and HTML. Hear is what I got so far.

<p>Thank you for visiting Niland's Place Campsite today. I notice that you didn't complete your   									purchase today. Could you answer four quick questions to help us understand why?</p>
<blockquote>
  <p>I chose not to complete the purchase today because: (select top 3 reasons)</p>
  <input name="OrderTotalHigh" type="checkbox" value="1" />
  
Order total was higher than I expected  <br />
  <input name="ShippingHigh" type="checkbox" value="1" />
  
Cost of shipping too high  <br />
  <input name="OutOfStock" type="checkbox" value="1" />
  
Products out of stock  <br />
  <input name="PersonalInfo" type="checkbox" value="1" />
  
Too much personal information requested  <br />
  <input name="WebsiteSecurity" type="checkbox" value="1" />
  
Concerned about the website's security  <br />
  <input name="ChangeMind" type="checkbox" value="1" />
  
Changed mind about products  <br />
  <input name="Comparison" type="checkbox" value="1" />
  
Comparison shopping   <br />
  <input name="PurchaseLater" type="checkbox" value="1" />
  
Will purchase later  <br />
  <input name="CheckoutLong" type="checkbox" value="1" />
  
Checkout process is too long  <br />
  <input name="CheckoutConfusing" type="checkbox" value="1" />
  
Checkout process is confusing  <br />
  <input name="Navigation" type="checkbox" value="1" />
  
Poor site navigation  <br />
  <input name="ProductInfo" type="checkbox" value="1" />
  
Insufficient product information  <br />
  <input name="UnclearDelivery" type="checkbox" value="1" />
  
Site unclear on delivery times  <br />
  <input name="OrderTracking" type="checkbox" value="1" />
  
No order tracking   </blockquote>

That is the HTML I want to use. the value in the database is 1 BOOL for every item checked. I have constructed a PHP file to connect with the database. but all I get is the login page.

<?php
  $DBhost = "supremecenter48.com ";
  $DBuser = "makoshark";
  $DBpass = "xxxxxxx";
  $DBName = "makoshark_survey";
  $table = "exit_reason";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");

@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
?>

Next I need a way to input the date, and then insert a 1 (true) for each checkbox. Here are the corresponding fields

CREATE TABLE `exit_reason` (
  `date` DATE NOT NULL, 
  `WebPath` VARCHAR(255) NOT NULL, 
  `OrderTotalHigh` BOOL DEFAULT '0' NOT NULL, 
  `ShippingHigh` BOOL DEFAULT '0' NOT NULL, 
  `OutOfStock` BOOL DEFAULT '0' NOT NULL, 
  `PersonalInfo` BOOL DEFAULT '0' NOT NULL, 
  `WebsiteSecurity` BOOL DEFAULT '0' NOT NULL, 
  `ChangeMind` BOOL DEFAULT '0' NOT NULL, 
  `Comparison` BOOL DEFAULT '0' NOT NULL, 
  `PurchaseLater` BOOL DEFAULT '0' NOT NULL, 
  `CheckoutLong` BOOL DEFAULT '0' NOT NULL, 
  `CheckoutConfusing` BOOL DEFAULT '0' NOT NULL, 
  `ProductInfo` BOOL DEFAULT '0' NOT NULL, 
  `UnclearDelivery` BOOL DEFAULT '0' NOT NULL, 
  `OrderTracking` BOOL DEFAULT '0' NOT NULL, 
  `cart_empty` BOOL DEFAULT '0' NOT NULL, 
  `Item` VARCHAR(255) NOT NULL, 
  `index` INT(255) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`date`),
  INDEX (`index`)
)
TYPE = myisam

And lastly the item they were looking at from my zen cart and Or if the cart was emty
Thanks

Hi,
I am just writing some code that may or may not help you... I will post another reply when it is done - just wanted to let you know that I am atempting it lol.
ParkeyParker

OK, I made a couple of modifications to your HTML (made it into a form with submit and reset buttons). It sends the output to submitform.php (which you can change if you want to):

<form method="post" action="submitform.php">
  <p>I chose not to complete the purchase today because: (select top 3 reasons)</p>
  <input name="OrderTotalHigh" type="checkbox" value="1" /> Order total was higher than I expected  <br />
  <input name="ShippingHigh" type="checkbox" value="1" /> Cost of shipping too high  <br />
  <input name="OutOfStock" type="checkbox" value="1" /> Products out of stock  <br />
  <input name="PersonalInfo" type="checkbox" value="1" /> Too much personal information requested  <br />
  <input name="WebsiteSecurity" type="checkbox" value="1" /> Concerned about the website's security  <br />
  <input name="ChangeMind" type="checkbox" value="1" /> Changed mind about products  <br />
  <input name="Comparison" type="checkbox" value="1" /> Comparison shopping   <br />
  <input name="PurchaseLater" type="checkbox" value="1" /> Will purchase later  <br />
  <input name="CheckoutLong" type="checkbox" value="1" /> Checkout process is too long  <br />
  <input name="CheckoutConfusing" type="checkbox" value="1" /> Checkout process is confusing  <br />
  <input name="Navigation" type="checkbox" value="1" /> Poor site navigation  <br />
  <input name="ProductInfo" type="checkbox" value="1" /> Insufficient product information  <br />
  <input name="UnclearDelivery" type="checkbox" value="1" /> Site unclear on delivery times  <br />
  <input name="OrderTracking" type="checkbox" value="1" /> No order tracking   </blockquote> <br />
  <input type="reset"  />&nbsp;&nbsp;<input type="submit" value="Submit" />
</form>

Next you need to create the submitform.php document:

<?php
$info[0] = $_REQUEST['OrderTotalHigh'] ;
$info[1] = $_REQUEST['ShippingHigh'] ;
$info[2] = $_REQUEST['OutOfStock'] ;
$info[3] = $_REQUEST['PersonalInfo'] ;
$info[4] = $_REQUEST['WebsiteSecurity'] ;
$info[5] = $_REQUEST['ChangeMind'] ;
$info[6] = $_REQUEST['Comparison'] ;
$info[7] = $_REQUEST['PurchaseLater'] ;
$info[8] = $_REQUEST['CheckoutLong'] ;
$info[9] = $_REQUEST['CheckoutConfusing'] ;
$info[10] = $_REQUEST['Navigation'] ;
$info[11] = $_REQUEST['ProductInfo'] ;
$info[12] = $_REQUEST['UnclearDelivery'] ;
$info[13] = $_REQUEST['OrderTracking'] ;

//Add Validation to check that only 3 items have been checked.
$i=0;

for($j=0; $j<=13; $j++){
	if ($info[$j] == true){
		$i++;
		$final[$j] = '1';
	} else {
		$final[$j] = '0';
	}
	if ($i==3){
		for($k=$j+1; $k<=13; $k++){
			$final[$k] = '0';
		}
		break;
	}
}

//Get the date
$today = date('d/m/o');

//Get the WebPath
//$webPath = 'Insert code to get current web path here';

//Connect to the database
$DBhost = "supremecenter48.com ";
  $DBuser = "makoshark";
  $DBpass = "xxxxxxx";
  $DBName = "makoshark_survey";
  $table = "exit_reason";
$con = mysql_connect($DBhost,$DBuser,$DBpass);
if (!$con){
  die('Could not connect: ' . mysql_error());
}

@mysql_select_db("$DBName") or die("Unable to select database $DBName");

for($l=0; $l<=13; $l++){
	$values.=$final[$l] . ", ";
}
$insertQuery = "INSERT INTO $table VALUES ($today, webPath, $values, cartEmpty, Item)";

echo $insertQuery; //This is for debugging purposes at the moment

mysql_query($insertQuery);
mysql_close($con);
?>

I am sorry that I was unable to get the current file path because I wasn't sure which file (web) path you want to get. Also I do not have any knowledge of Zen Cart to get any information about the cart from that however I have filled in the required parts of the SQL Query where you would need to put the information once you have found it.
With $insertQuery there is the plain text "webPath", Earlier in the code I left a variable for you to input this information into if you can find some script to do it for you so you just need to add a '$' in front of webPath for it to work correctly in the SQL Query.
I hope all of this made sense and I am sorry if i misunderstood you in places or if my code is not the 'best' way to go about it however it does appear to work.
ParkeyParker
PS if anything needs explaining then either reply here or PM me.

After thought on what I want out of the check boxes I have come up with this

<blockquote> 
  <input name="question[]" type="checkbox" value="OrderTotalHigh" />&nbsp;&nbsp;Order total was higher than I expected  <br />
  <input name="question[]" type="checkbox" value="ShippingHigh" />&nbsp;&nbsp;Cost of shipping too high  <br />
  <input name="question[]" type="checkbox" value="OutOfStock" />&nbsp;&nbsp;Products out of stock  <br />
  <input name="question[]" type="checkbox" value="PersonalInfo" />&nbsp;&nbsp;Too much personal information requested  <br />
  <input name="question[]" type="checkbox" value="WebsiteSecurity" />&nbsp;&nbsp;Concerned about the website's security  <br />
  <input name="question[]" type="checkbox" value="ChangeMind" />&nbsp;&nbsp;Changed mind about products  <br />
  <input name="question[]" type="checkbox" value="Comparison" />&nbsp;&nbsp;Comparison shopping   <br />
  <input name="question[]" type="checkbox" value="PurchaseLater" />&nbsp;&nbsp;Will purchase later  <br />
  <input name="question[]" type="checkbox" value="CheckoutLong" />&nbsp;&nbsp;Checkout process is too long  <br />
  <input name="question[]" type="checkbox" value="CheckoutConfusing" />&nbsp;&nbsp;Checkout process is confusing  <br />
  <input name="question[]" type="checkbox" value="Navigation" />&nbsp;&nbsp;Poor site navigation  <br />
  <input name="question[]" type="checkbox" value="ProductInfo" />&nbsp;&nbsp;Insufficient product information  <br />
  <input name="question[]" type="checkbox" value="UnclearDelivery" />&nbsp;&nbsp;Site unclear on delivery times  <br />
  <input name="question[]" type="checkbox" value="OrderTracking" />&nbsp;&nbsp;No order tracking
</blockquote>
<input type="submit" value="submit" name="submit">
</form>

What would be nice is a for each checkbox get its checked state and the value that should match the MySQL field
then place a true or 1 into the database

This article has been dead for over six months. Start a new discussion instead.