 |
|
|
|
| |
|
|
 |
Subscribe to the Penthouse Lingerie Mailing List |
 |
|
// Initialize variables
$error = "";
$response = "";
#=================================#
# CONFIG #
#=================================#
// Edit this with your own database information
$sql_host ="localhost";
$sql_user ="root";
$sql_db ="penthouselingerie/xcart_newslist_subscription";
$sql_password ="$tag$h0p";
// End Config
#=================================#
# FUNCTIONS #
#=================================#
function check_email($str) {
//returns 1 if valid email, 0 if not
if(ereg("^.+@.+\\..+$", $str)) { return 1; }
else { return 0; }
}
#=================================#
# ON POST COMMANDS #
#=================================#
if ($_POST['mode'] != "") {
// Connect and Select a Database
$link = mysql_connect($sql_host, $sql_user, $sql_password) or die ("Couldn't connect to MYSQL Database");
mysql_select_db($sql_db) or die("Could not select the database '" . $sql_db . "'. Are you sure it exists?");
// Format the email address
$email = $_POST['email'];
$email = strip_tags($email);
$email = addslashes($email);
// Check for valid email address
if (check_email($email) != 1) { $error = Y; }
if ($error != "") {
$response = "ERROR: Invalid E-mail address!";
}
// If there is not an error, we check the mode
// Subscribe
elseif ($_POST['mode'] == "subscribe") {
$result = mysql_query("select email from xcart_maillist where email='$email' LIMIT 1");
$emailcheck = mysql_fetch_row($result);
$emailcheck = $emailcheck[0];
mysql_free_result($result);
if ($emailcheck != "") { $response = "ERROR: E-mail is already subscribed to the Newsletter."; }
else {
mysql_query("INSERT INTO xcart_maillist values('$email', now())");
$response = "ADDED: E-mail address successfully added to the Newsletter!";
}
}
// Unsubscribe
elseif ($_POST['mode'] == "unsubscribe") {
$result = mysql_query("select email from xcart_maillist where email='$email' LIMIT 1");
$emailcheck = mysql_fetch_row($result);
$emailcheck = $emailcheck[0];
mysql_free_result($result);
if ($emailcheck == "") { $response = "ERROR: E-mail address is not subscribed to the Newsletter."; }
else {
mysql_query("DELETE FROM xcart_maillist where email='$email' LIMIT 1");
$response = "REMOVED: E-Mail address has been successfully removed from the Newsletter.";
}
}
}
?>
Enter your e-mail in the form below to subscribe to our Mailing List! Receive news about our collections, as well as coupons, discounts, and information about upcoming sales!
To unsubscribe, enter your e-mail below and click "Unsubscribe".
|
|
|
|
|
|
|