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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.