Hi,
I want to have this form email the answers to an email address - that works. But if there is an error i want it to highlight the error parts in red (set by style sheet) - cant seem to get that to work - everytime i submit the page it just refreshes to a blank form.
Below is the code.
<?
require 'functions/constants.php';
require 'functions/class.GeneralFunctions.php';
require 'functions/mysql_connect.php';
require 'functions/class.Session.php';
$sess = new Session();
//Do all the variables needed before page output
$meta_title = "DFNI 2009 Retailer Voting Form";
$meta_description = "DFNI 2009 Retialer Voting Form";
$page_type = "DFNI 2009 Retailer Voting Form";
$page_title = "2009 Retailer Voting Form";
//*****
//Template Includes
include (PATH_TEMPLATES."header.php");
include (PATH_TEMPLATES."nav_top.php");
include (PATH_TEMPLATES."nav_left.php");
//***
//***Get Year
$year = archive_is_year();
//**main content
?>
<?php
if($errordata){
?><span class="largetxt_red">Please complete the fields marked in red. </span>
<?
}
function postCode($postcode) {
$preg = "^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$";
if(eregi($preg, $postcode)){
$match = true;
} else {
$match = false;
}
return $match;
}
function phoneNumber($number) {
$number = str_replace(array('(', ')', '-', '+', '.', ' '), '', $number);
$preg = "/^0[125789][0-9]{9,10}$/";
$match = (preg_match($preg, $number)) ? true : false;
return $match;
}
?>
<link href="form.css" type="text/css" rel="stylesheet" />
<div class="content" class="vote_body">
<h1>2009 Retailer Voting Form</h1>
<form action="<? echo $PHP_SELF; ?>" name="Vote" class="vote_form">
<div class="vote_body"><br />Airport Authority With The Most Supportive Approach To Travel Retail <span class="small">(not open to airport authorities)</span></div>
<div align="right" title="Airport_Authority">
<span class="<? if($errordata['airport_authority_first']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">First Choice</span>
<input class="vote_input" type="text" name="Airport_Authority_first" size="60" />
<br />
<span class="<? if($errordata['airport_authority_second']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Second Choice</span>
<input class="vote_input" type="text" name="Airport_Authority_second" size="60" />
<br />
<span class="<? if($errordata['airport_authority_third']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Third Choice</span>
<input class="vote_input" type="text" name="Airport_Authority_third" size="60" />
<br />
</div>
<div>
<span class="vote_body"><br />Supplier Of The Year</span> <span class="vote_body" class="small">(in terms of service, support, promotions, training, etc)</span></div>
<div align="right" title="supplier_of_the_year">
<span class="<? if($errordata['supplier_of_the_year_first']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">First Choice</span>
<input class="vote_input" type="text" name="supplier_of_the_year_first" size="60"/>
<br />
<span class="<? if($errordata['supplier_of_the_year_second']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Second Choice</span>
<input class="vote_input" type="text" name="supplier_of_the_year_second" size="60" />
<br />
<span class="<? if($errordata['supplier_of_the_year_third']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Third Choice</span>
<input class="vote_input" type="text" name="supplier_of_the_year_third" size="60" />
<br />
</div>
<div class="vote_body"><br />Best New Shop Opening <span class="small"> since January 2008 (please name operator and location)</span></div>
<div align="right" title="best_new_shop_opening">
<span class="<? if($errordata['best_new_shop_nomination']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Nomination</span>
<input class="vote_input" type="text" name="best_new_shop_nomination" size="60" />
<br />
<span class="<? if($errordata['best_new_shop_reason']){ ?>largetxt_red<? } else { ?>reason<? } ?>">Reason</span>
<textarea class="vote_input" name="best_new_shop_reason" rows="3" cols="38"></textarea>
<br />
</div>
<div>
<span class="vote_body"><br />Contact Details</span></div>
<div align="right" title="name">
<span class="<? if($errordata['name']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Name</span>
<input class="vote_input" type="text" name="Name" size="60" />
<br />
<span class="<? if($errordata['position']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Position</span>
<input class="vote_input" type="text" name="Position" size="60" />
<br />
<span class="<? if($errordata['company']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Company</span>
<input class="vote_input" type="text" name="company" size="60" />
<br />
<span class="<? if($errordata['address1']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Address 1</span>
<input class="vote_input" type="text" name="Address1" size="60" />
<br />
<span class="<? if($errordata['address2']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Address 2</span>
<input class="vote_input" type="text" name="Address2" size="60" />
<br />
<span class="<? if($errordata['address3']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Address 3</span>
<input class="vote_input" type="text" name="Address3" size="60" />
<br />
<span class="<? if($errordata['postcode']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Postcode</span>
<input class="vote_input" type="text" name="Postcode" size="60" />
<br />
<span class="<? if($errordata['Telephone']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Tel:</span>
<input type="text" class="vote_input" name="telephone" size="60" />
<br />
<span class="<? if($errordata['fax']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Fax:</span>
<input class="vote_input" type="text" name="fax" size="60" />
<br />
<span class="<? if($errordata['email']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">Email</span>
<input class="vote_input" type="text" name="email" size="60" />
<br />
</div>
<div align="right" class="<? if($errordata['security_code']){ ?>largetxt_red<? } else { ?>vote_body<? } ?>">
<img src="CaptchaSecurityImages.php"/>
Security Code:
<input class="vote_input" id="security_code" name="security_code" type="text" />
<input class="vote_input" type="submit" name="Submit" value="Submit" size="60" />
<input type="hidden" name="mail" value="1">
</div>
</form>
<?
$airport_authority_first = $_REQUEST['airport_authority_first'];
$airport_authority_second = $_REQUEST['airport_authority_second'];
$airport_authority_third = $_REQUEST['airport_authority_third'];
$supplier_of_the_year_first = $_REQUEST['supplier_of_the_year_first'];
$supplier_of_the_year_second = $_REQUEST['supplier_of_the_year_second'];
$supplier_of_the_year_third = $_REQUEST['supplier_of_the_year_third'];
$shopNomination = $_REQUEST['best_new_shop_nomination'];
$shopReason = $_REQUEST['best_new_shop_reason'];
$name = $_REQUEST['name'];
$company = $_REQUEST['company'];
$position = $_REQUEST['position'];
$address1 = $_REQUEST['address1'];
$address2 = $_REQUEST['address2'];
$address3 = $_REQUEST['address3'];
$postcode = $_REQUEST['postcode'];
$number = $_REQUEST['telephone'];
$fax = $_REQUEST['fax'];
$email = $_REQUEST['email'];
$to = "me@me.com";
$subject = "Online Retailer Voting";
$message = "
Airport Authority with the Most Supportive Approach to Travel Retail \n\n
Fisrt: $airport_authority_first \n
Second: $airport_authority_second \n
Third: $airport_authority_third \n\n
Airport Authority with the Most Supportive Approach to Travel Retail \n\n
Fisrt: $supplier_of_the_year_first \n
Second: $supplier_of_the_year_second \n
Third: $supplier_of_the_year_third \n\n
Best New Shop Opening \n\n
Nomination: $shopNomination \n
Reason: $shopReason \n\n
This information was sent from \n
Name: $name \n
Position: $position \n
Company: $company \n
Address: \n
$address1, \n
$address2, \n
$address3, \n
Postcode: $postcode
Telephone: $number \n
Fax: $fax \n
Email: $email \n";