View Single Post
  #1 (permalink)  
Old Nov 14th, 2007, 12:07
Emzi's Avatar
Emzi Emzi is offline
SuperMember

SuperMember
Join Date: Sep 2007
Location: Manchester
Age: 25
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] sending email once form submitted

Hey all, I'm back again...

I have a newsletter form that basically someone inputs their email address and it is submitted to the database.

I want then to send an email to the email address to confirm that they've been put on the newsletter, but I have no clue how to do this.

I've been looking on the internet but most of the stuff is for contact forms etc. which doesn't really help me.

Here's my code:

PHP: Select all

<?php require_once('Connections/ukjobsite.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO tblNEWSLETTER_SIGNUP (signup_id, email_address, date_registered, client_ip, unsubscribed) VALUES (%s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['signup_id'], "int"),
                       
GetSQLValueString($_POST['email_address'], "text"),
                       
GetSQLValueString($_POST['date_registered'], "date"),
                       
GetSQLValueString($_POST['client_ip'], "text"),
                       
GetSQLValueString($_POST['unsubscribed'], "int"));
  
mysql_select_db($database_ukjobsite$ukjobsite);
  
$Result1 mysql_query($insertSQL$ukjobsite) or die(mysql_error());
  
$insertGoTo "newsletter_signup_success.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
  
ob_get_contents();
  
ob_end_clean();
  
header(sprintf("Location: %s"$insertGoTo));
  exit();
}
?>
<img src="images/grey_small_top.gif" alt="UK Jobs in Recruitment" /><div class="grey_small">
<div class="small_content_holder"><img src="images/newsletter.gif" alt="UK Jobs in Recruitment" /><br />
Submit your email address to sign up to our 
newsletter.<br />
<div class="form_text">
<div class="form_padding"><b>Email:</b></div>
</div>
<div class="form_object">
<div class="form_padding">
<form action="<?php echo $editFormAction?>" method="post" name="form1" id="form1"><input name="email_address" type="text" class="textfield"/></div>
<input type="submit" class="submit" value="SUBMIT" />  <input type="hidden" name="signup_id" value="" />
  <input type="hidden" name="client_ip" value="<?php echo $_SERVER['REMOTE_ADDR'?>" />
  <input type="hidden" name="unsubscribed" value="0" />
  <input type="hidden" name="MM_insert" value="form1" />
</form></div><div class="clear"></div></div></div><img src="images/grey_small_bot.gif" alt="UK Jobs in Recruitment" />
Anyone care to help? Thanks xx
Reply With Quote