Jump to content

[SOLVED] PHP script To Send Email From MYSQL


jstratos

Recommended Posts

I have a simple SIGN-UP form which sends information to the mysql database TABLE named "UPDATES".

 

I want to generate a form that will allow me to type in a message and then send it to ALL the email addresses stored in the TABLE "UPDATES"

Here's my PHP:

<?php include 'config.php' ?>
<?php include 'opendb.php' ?>
<?php
// Form1 starts here
$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 updates (name, email, address, city, state, zip, phone, comments) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['name'], "text"),
				   GetSQLValueString($_POST['email'], "text"),
				   GetSQLValueString($_POST['address'], "text"),
				   GetSQLValueString($_POST['city'], "text"),
				   GetSQLValueString($_POST['state'], "text"),
				   GetSQLValueString($_POST['zip'], "text"),
				   GetSQLValueString($_POST['phone'], "text"),
				   GetSQLValueString($_POST['comments'], "text"));


  mysql_select_db(ABC_company);
  $Result1 = mysql_query($insertSQL) or die(mysql_error());

  $insertGoTo = "../index.php?p=thanks";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

<html>
BlaBlaBla
</html>

<?php include 'closedb.php' ?>

 

I've looked around in your forum but can't seem to find anything 'simple'?

 

Any one have anything?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.