$sys_dbhost='localhost';
$sys_dbuser='saltwate_saltwat';
$sys_dbpasswd='huih35flc';
$sys_dbname='saltwate_sw1';
function db_connect() {
global $sys_dbhost,$sys_dbuser,$sys_dbpasswd,$sys_dbname;
$conn = mysql_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd);
if (!$conn) {
echo mysql_error();
}
mysql_select_db($sys_dbname);
return $conn;
}
function db_query($qstring,$print=0) {
return @mysql_query($qstring);
}
function validate_email ($address) {
return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $address));
}
db_connect();
session_start();
function subscribe($forename,$surname,$address,$address2,$town_city,$county,$postcode,$telephone,$email,$notes) {
// Check all required info present
if (!email)
return FALSE;
// Check for duplicate info
//if (($forename == $email) || ($surname == $email) || ($county == $postcode) || ($surname == $postcode) || ($forename == $telephone) || ($forename == $county) || ($address == $email))
// return FALSE;
// Validate email address
//if ($email)
// if (!validate_email($email))
// return FALSE;
// Timezone hack :/
putenv ('TZ=Europe/Amsterdam');
mktime(0,0,0,1,1,1970);
$array = localtime();
if ($array[8]) {
$thedate = date("j/m/Y",time()-3600);
$thetime = date("H:i",time()-3600);
} else {
$thedate = date("j/m/Y");
$thetime = date("H:i");
};
// Check for dupe IP address
//$ip = $_SERVER['REMOTE_ADDR'];
//if($_SESSION['swip'] == md5($ip))
// return FALSE;
//else
// $_SESSION['swip'] = md5($ip);
// Enter message into contact db table
$sql="INSERT INTO mailing_list (forename,surname,address,address2,town_city,county,postcode,telephone,email,notes,timestamp)"
."VALUES ('$forename','$surname','$address','$address2','$town_city','$county','$postcode','$telephone','$email','$notes','". time() ."')";
$result=db_query($sql);
if (!$result)
return FALSE;
// Email message
$message = "SALTWATER Mailing List Subscription".
"\n\nDate: ".$thedate.
"\nTime: ".$thetime.
"\n\nForename: ".$forename.
"\nSurname: ".$surname.
"\nAddress: ".$address.
"\nAddress2: ".$address2.
"\nTown_city: ".$town_city.
"\nCounty: ".$county.
"\nPostcode: ".$postcode.
"\nTelephone: ".$telephone.
"\nEmail: ".$email.
"\nNotes: ".$notes;
mail ('info@saltwater.co.uk','SALTWATER Mailing List Subscription',$message,'From: '.$email);
return TRUE;
};
?>
SALTWATER
if(isset($_POST['Submit'])) {
if(subscribe($_POST['forename'],$_POST['surname'],$_POST['address'],$_POST['address2'],$_POST['town_city'],$_POST['county'],$_POST['postcode'],$_POST['telephone'],$_POST['email'],$_POST['notes']))
echo '
THANK YOU
You are now subscribed to the
SALTWATER GALLERY mailing list
To download your free wallpaper please
right click one of the following links and select "save as":
800x600 | 1024x768
';
else
echo '
We are sorry but there is a problem with your information.
Please click here to try again, making sure to fill out every box correctly. Thank you.
';
} else {
?>
MAILING LIST
Join our mailing list to keep up to date with all the latest happenings at Saltwater. Simply enter your details and press submit.
Note: Your details will not be shared with any 3rd party organisations. |
|
}; ?>