Created
May 19, 2013 16:03
-
-
Save amkaos/5608094 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// named connect.php | |
// usable constants | |
define('DB_NAME', 'nameOfDatabase'); | |
define('DB_USER', 'UserName'); | |
define('DB_PASSWORD', 'UserPassword'); | |
define('DB_HOST', 'localhost'); | |
$connect = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); | |
if(!$connect) { | |
die('Could not connect: ' .mysql_error()); | |
} | |
$db_selected = mysql_select_db(DB_NAME,$connect); | |
if(!$db_selected) { | |
die('Can\'t use' . DB_NAME . ':' .mysql_error()); | |
} | |
echo 'Connected successfully'; | |
?> | |
// I GET THE "CONNECTED SUCCESSFULLY" ECHO ON PAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('connect.php'); | |
// change php.ini smtp line | |
//ini_set( "mail.tap.com"); i am using an actual host and this line is for | |
xaamp | |
// i did try leaving the line uncommented but it did not make any difference | |
// standard mail header | |
$headers = "From: tap.com"; | |
// get meessage to send | |
$message = $_GET['message']; | |
// loop through names / emails on index form | |
for ($x=0; $x<count($_GET); $x++) | |
{ | |
if ($_GET["mail_$x"]) | |
{ | |
// mail setup | |
$to = $_GET["mail_$x"]; | |
$subject = "News From Tap "; | |
$body = "Dear " . $_GET["name_$x"] . " | |
\n\n $message \n\n Josh \n\n Tap "; | |
mail($to, $subject, $body, $headers ); | |
} | |
} | |
echo "All Mail Has Been Processed"; | |
?> | |
// after i hit 'Submit' i get 'Connected successfully All Mail Has Been | |
Processed' | |
//// but no emails are sent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this the actual form | |
<?php | |
require('connect.php'); | |
echo"<h1>Mailing List</h1>Send To<p>"; | |
// setup variable | |
$mailcount = 0; | |
$namecount = 0; | |
$get = mysql_query("SELECT * from admin_table"); | |
echo "<form action='send.php' method='GET'>"; | |
while ($getrow = mysql_fetch_assoc($get)) | |
{ | |
echo "<input type = 'checkbox' name = 'mail_ ".$mailcount++." ' value | |
= '".$getrow ['email'] ."' CHECKED > | |
".$getrow['fullname'] . " (".$getrow['email'].") | |
<input type = 'hidden' name='name_ ".$namecount++."' value = | |
'".$getrow ['fullname'] ."'> | |
<br> "; | |
} | |
echo "<p> Message: <br><textarea name = 'message' ></textarea> <p> | |
<input type = 'submit' name = 'submit' value = 'Send' > | |
</form>"; | |
?> | |
// This works just as it should (list of names and emails from database)and | |
// after i hit 'Submit' i get 'Connected successfully All Mail Has Been | |
Processed' | |
// but no emails are sent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment