Tag: forms

Contact Form 7 and Bluehost

Had some issues setting up a site developed by other developers. Aaaaaand this is why Gravity Forms is better. But, anyway, the solution was simple enough: http://wordpress.org/support/topic/contact-form-7-not-working-6

Update: Come to find the same issue with Gravity Forms on a Liquid Web VPS. I realized that (duh) this would always be an issue for clients who use a remote mail exchanger, as the server won’t even look outside itself if it thinks the mail exchanger is local. So, the steps for a cPanel host (which is most of my clients):

cPanel->Mail->MX Entry->Choose Domain-> Find MX Record and look for “Email Routing”->Change to Remote Exchanger.

Of course, ONLY do this for sites that aren’t using the web host to collect mail!

Gravity forms CSS tricks

http://kevinshoffner.com/wordpress/tipstricks/custom-css-gravity-forms/

Here is a quick list of all of the built-in classes:

Checkboxes and Lists Fields

gf_list_2col

= 2 columned List

gf_list_3col

= 3 columned List

gf_list_4col

= 4 columned

gf_list_5col

= 5 columned

Two Columns of Text Fields side by side

gf_left_half

= The left column

gf_right_half

= The right column

Three Columns side by side

gf_left_third

= Left column

gf_middle_third

= Middle column

gf_right_third

= Right column

Some other miscellaneous styles

gf_scroll_text

= Gets a scroll box into place, for those long sections where you need to give your visitor lots of information
scrolling-text

gf_hide_ampm

= If you want to hide the AM/PM portion of the Time field

gf_list_inline

= Simpliar to the above gf_list classes, but just show up next to each other using the amount of space the content can use on each line, instead of making it fit within 2,3,4,5 columns.

gf_hide_charleft

= Do not display the amount of characters left / character counter

I’ve not found a great use for these, but they are available:

gf_list_height_25

= 25 pixels between list items

gf_list_height_50

= 50 pixels between list items

gf_list_height_75

= 75 pixels between list items

gf_list_height_100

= 100 pixels between list items

gf_list_height_125

= 125 pixels between list items

gf_list_height_150

= 150 pixels between list items

Down and Dirty PHP mailer with backup CSV

<?php
if($_POST){
	//set up variables
	$to = '';
	$from = '';
	$cc = '';
	$bcc = '';
	$subject = '';
	$backup_filename = '';
	//loop through fields
	foreach($_POST AS $k => $v){
		$message .= '<li>'.$k.': '.$v."</li>\n";
		$csv_header .= $k.',';
		$csv_record .= $v.',';
	}
	//clean up for csv
	$csv_header .= "\n";
	$csv_record .= "\n";
	//htmlize message
	$message = '<html>
	<head>
	  <title>'.$subject.'</title>
	</head>
	<body>
	  <ul>'.$message.'</ul>
	</body>
	</html>';
	// To send HTML mail, the Content-type header must be set
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	// Additional headers
	//$headers .= 'To:' . $to . "\r\n";
	$headers .= 'From:' . $from . "\r\n";
	$headers .= 'Cc:'. $cc . "\r\n";
	$headers .= 'Bcc:'. $bcc . "\r\n";
	// Mail it
	mail($to, $subject, $message, $headers);
	//store backup data
	if (!file_exists($backup_filename)) {
		$csv_record = $csv_header.$csv_record;
	}
	if (!$handle = fopen($backup_filename, 'a')) {
		exit;
	}
	if (fwrite($handle, $csv_record) === FALSE) {
		exit;
	}
	fclose($handle);
	//done.
}

Test a Form Entry Against a CSV File.

The simple way.

<?php
/**
* Test for post; check against list; return error if bad.
*/
function check_data($input){
	//if the input is null, go no further;
	if(empty($input))
		return 'Please enter a valid code.';
	//if the input isn't 6 alphanumeric characters, go no further
	if(!preg_match('/[A-Za-z0-9]{6}/i',$input))
		return 'The code provided is not valid.';
	//finally, test against the list
	$filepath = dirname(__FILE__).'/data/datafile.csv';
	if (($list = fopen($filepath, "r")) !== FALSE) {
		while (($data = fgetcsv($list, 1000, ',')) !== FALSE) {
			if($input == $data[0]){
				header('Location:'.$data[1]);
				die();
			}
		}
		fclose($list);
	}
	return 'The code provided is not valid.';
	}
if($_POST)	
$error = check_data($_POST['code']);
?>