[SOLVED] sending email once form submitted

This is a discussion on "[SOLVED] sending email once form submitted" within the PHP Forum section. This forum, and the thread "[SOLVED] sending email once form submitted are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 14th, 2007, 12:07
Emzi's Avatar
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 14th, 2007, 13:09
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: sending email once form submitted

When you insert the email address, just call the mail() function....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 14th, 2007, 13:56
Emzi's Avatar
SuperMember

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

As I've said in my previous post I'm only familiar with PHP, I'm not an expert, so when you say call the mail function it doesn't mean anything to me.

I tried adding this:

PHP: Select all

if (mail ($email_addresstesttest"From: info@ukjobs.com\r\n\r\n"));
{
$sent true;
}else{
$sent false;

And I tried it in many various ways but to no avail.

Please can you be more clear in your explainations? I understand most people don't want to go "here's the code, this will work" etc. but more of a clue as to where to put something, or how it works etc. will be useful.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Nov 21st, 2007, 14:17
Emzi's Avatar
SuperMember

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

I marked this as solved but it's been opened again?

Anyway, I'll mark it as solved again as I got help from a colleague.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Nov 21st, 2007, 14:21
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: [SOLVED] sending email once form submitted

That was me ... hehe... sorry 'about that. There's was a bunch of closed and solved threads and some didn't seem to be solved ... like yours.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Nov 21st, 2007, 14:25
Emzi's Avatar
SuperMember

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

Ahh ok No probs. I should've explained why it was solved
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP mail() --> Making a Form / Validating Input / Sending an email c010depunkk PHP Forum 4 Jan 17th, 2008 06:35
[SOLVED] Form to email with checkbox itsdesign PHP Forum 4 Oct 29th, 2007 00:57
sending form info to email eon201 PHP Forum 2 Oct 26th, 2007 15:34
PHP email form not sending email Kurt PHP Forum 1 Oct 12th, 2007 04:26
About sending form-data to an email address a.jenery Web Page Design 4 Mar 3rd, 2006 12:17


All times are GMT. The time now is 02:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42