Hi,
How would I allow the email addresses, which hva been entered into the user registration form to be sent to the mailing list in Mailchimp?
Here is the code for the page which contains the form with the email field (If this helps):
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "loginadmin.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<!--HEADER CONTENT START --><head>
<style type="text/css">
body{ margin:0px; background:#FFF;}
.header {
height:165px;
background:#FFF;
border:1px solid#CCC;
position:fixed;
width:100%;
top:0px;
}
</style>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<div class="header"><?php include('defaultheader.php');?></div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<!--HEADER CONTENT END -->
<html>
<title>Create New Account</title>
</html>
<?php require_once('Connections/drama_database.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "newaccountform")) {
$insertSQL = sprintf("INSERT INTO users (username, password, firstname, lastname, email, userlevel) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['username2'], "text"),
GetSQLValueString($_POST['password2'], "text"),
GetSQLValueString($_POST['firstname2'], "text"),
GetSQLValueString($_POST['lastname2'], "text"),
GetSQLValueString($_POST['email2'], "text"),
GetSQLValueString($_POST['userlevel'], "int"));
mysql_select_db($database_drama_database, $drama_database);
$Result1 = mysql_query($insertSQL, $drama_database) or die(mysql_error());
$insertGoTo = "adminusermanagement.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_drama_database, $drama_database);
$query_newuser = "SELECT * FROM users";
$newuser = mysql_query($query_newuser, $drama_database) or die(mysql_error());
$row_newuser = mysql_fetch_assoc($newuser);
$totalRows_newuser = mysql_num_rows($newuser);
?>
<div align="center">
<h1>Create New Account</h1>
</div>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<div align="center">
<form action="<?php echo $editFormAction; ?>" method="POST" name="newaccountform" id="newaccountform">
<table width="416" border="0">
<tr>
<td width="94" class="formtag">First Name</td>
<td width="315"><span id="sprytextfield6">
<label for="firstname2"></label>
<input name="firstname2" type="text" class="formfield" id="firstname2" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Last Name</td>
<td><span id="sprytextfield7">
<label for="lastname2"></label>
<input name="lastname2" type="text" class="formfield" id="lastname2" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Email</td>
<td><span id="sprytextfield8">
<label for="email2"></label>
<input name="email2" type="text" class="formfield" id="email2" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td class="formtag">Username</td>
<td><span id="sprytextfield9">
<label for="username2"></label>
<input name="username2" type="text" class="formfield" id="username2" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Password</td>
<td><span id="sprytextfield10">
<label for="password2"></label>
<input name="password2" type="text" class="formfield" id="password2" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td class="formtag">Userlevel</td>
<td><label for="userlevel"></label>
<select name="userlevel" class="formfield" id="userlevel">
<option value="0" selected="selected">User</option>
<option value="1">Admin</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input name="createuser" type="submit" class="button" id="createuser" value="Create Account" /></td>
</tr>
</table>
<table width="147" border="0">
<tr> </tr>
<tr> </tr>
<tr> </tr>
<tr> </tr>
</table>
<input type="hidden" name="MM_insert" value="newaccountform">
</form>
</div>
<script type="text/javascript">
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6");
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7");
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "email");
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");
var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10");
</script>
<?php
mysql_free_result($newuser);
?>