Jump to content

Adding Images to emails with php


craigtolputt

Recommended Posts

Hi, I have an email form in php and flash and i would like to have a company logo in the email that goes to the subscriber.

 

Do i simply add this to the message part???

 

[color=red]$msg = "<img src="../images/logomain.gif" /><br/>";[/color]
$msg .= "Hello $firstName $lastName,<br/>";
$msg .= "We would like to thank you for joining our web site.<br/><br>";
$msg .= "Your Username is: $username<br/>";
$msg .= "Your Password is: $passwordsend<br/><br>";
$msg .= "Please keep these safe and if you have any questions, contact us at <br><br>";
$msg .= "<a href=\"mailto:[email protected]\">[email protected]</a>.";
mail($email,"Thanks for Registering!",$msg,$headers);

Link to comment
https://forums.phpfreaks.com/topic/114632-adding-images-to-emails-with-php/
Share on other sites

Yeah i think its right,,, this is what i have...

 

<?php
//include the connect script
include "connect.php";

/*THIS VARIABLE IS WHAT TABLE YOU ARE USING...IF YOU USED MY SQL FILE, THEN YOUR DEFAULT TABLE*/
/*NAME SHOULD BE 'userv2' AND YOU DO NOT NEED TO CHANGE ANYTHING, BUT IF YOU MADE YOUR OWN TABLE,*/
/*CHANGE THIS VARIABLE.*/
$tableName = "usersv2";

//Post all of the users information (md5 Encrypt the password)
$username = $_POST['username'];
$password = md5($_POST['password']);
$passwordsend = ($_POST['password']);
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];


//Generate confKey (this is used to determine which user it is when the user forget's their password.
function createConfKey() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$key = '';
while ($i <= 31) { 
	$num = rand() % 33;
	$tmp = substr($chars, $num, 1);
	$key = $key . $tmp;
	$i++;
}    
return $key;
}
$thekey = createConfKey();
//$theKey is the random 32 character string and then $confKey is the random 32 character string with md5 encryption.
$confKey = md5($thekey);
//grab all the usernames in the table
$sql1 = mysql_query("SELECT * FROM $tableName WHERE username = '$username'");
//grab all the emails in the table
$sql2 = mysql_query("SELECT * FROM $tableName WHERE email = '$email'");
//get number of results from both queries
$row1 = mysql_num_rows($sql1);
$row2 = mysql_num_rows($sql2);
//if there is a result it will be either 1 or higher
if($row1 > 0 || $row2 > 0) {
//echo username or email is already in use and deny registration.
echo "&msgText=Username or email already in use!";
} else {
//if there was no existing username or email, insert all their information into the database.
$insert = mysql_query("INSERT INTO $tableName (username,password,firstName,lastName,email,phone,address,city,state,zip,confKey) VALUES ('$username','$password','$firstName','$lastName','$email','$phone','$address','$city','$state','$zip','$confKey')") or die(mysql_error());
//This is required for and HTML email to be sent through PHP.
$headers = "From: [email protected]\r\n";
$headers.= "Subject: RedWeb Security Group Registration Details\r\n";
$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";
/******HERE YOU CAN EDIT WHAT YOU WANT THE EMAIL TO SAY WHEN THEY FORGET THEIR PASSWORD******/
/*																							*/
/*PHP Explained:                                                                            */
/*$msg are all the same variable, however, when you set the first one to just '=' and the   */
/*second one to '.=' it basically concatinates the two variables. For example:              */
/*																							*/
/*																							*/
/*										$a = 1;												*/
/*										$a .= 2;											*/
/*										$a .= 3;											*/
/*										echo $a;											*/
/*																							*/
/*										This will echo: 123									*/
/*																							*/
/*																							*/
/*	Be sure to include $firstName & $lastName somewhere in the message so the user knows 	*/
/*  what the message is																		*/
/*																							*/
/*																							*/
/*																							*/
/********************************************************************************************/
$msg = "<img src="../images/logomain.gif" /><br/>";
$msg .= "Hello $firstName $lastName,<br/>";
$msg .= "We would like to thank you for joining our web site.<br/><br>";
$msg .= "Your Username is: $username<br/>";
$msg .= "Your Password is: $passwordsend<br/><br>";
$msg .= "Please keep these safe and if you have any questions, contact us at <br><br>";
$msg .= "<a href=\"mailto:[email protected]\">[email protected]</a>.";
mail($email,"Thanks for Registering!",$msg,$headers);


//and echo "Successfully registered!" and take them to a "thanks for registering" frame in flash
echo "&msgText=Successfully registered!";
echo "&nameText=$firstName";
}

?>

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.