craigtolputt Posted July 15, 2008 Share Posted July 15, 2008 Hey Guys, Im pretty sure this isnt hard but i cant find any tuts on it. I want to add an image at the top of my registration email sent from php. This is my registration form.... <?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: admin@redwebsecurity.com\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 = "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:admin@redwebsecurity.com\">admin@redwebsecurity.com</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"; } ?> I thought it would be as simple as adding this line to the message section, but this just makes my form stop working. $msg .= "<img src="www.mysite.com/images/logo.gif" /><br/><br>"; Any ideas guys?? ??? Quote Link to comment Share on other sites More sharing options...
trq Posted July 15, 2008 Share Posted July 15, 2008 $msg .= "<img src=\"www.mysite.com/images/logo.gif\" /><br/><br>"; Quote Link to comment Share on other sites More sharing options...
craigtolputt Posted July 15, 2008 Author Share Posted July 15, 2008 Thanks Alot!! That worked great. so if your adding say an image or link or any html you have to put a \ before the " marks and / after them? is that the rule? sorry im a flash developer trying to figure php out/ cheers for answer Quote Link to comment Share on other sites More sharing options...
trq Posted July 15, 2008 Share Posted July 15, 2008 Strings are defined using either single or double quotes. If your string contains single or double quotes they will need to be escaped to stop the string ending prematurely. eg; echo 'this is "foo"'; echo "this is \"foo\""; echo 'this is \'foo\''; This is no different in flash. Quote Link to comment Share on other sites More sharing options...
craigtolputt Posted July 15, 2008 Author Share Posted July 15, 2008 Ah ok cheers, i think im getting it Quote Link to comment Share on other sites More sharing options...
craigtolputt Posted July 15, 2008 Author Share Posted July 15, 2008 Yep defo got it now !! i made the email a full html email with tables and images and animated gifs and everything. Cheers for the help. Quote Link to comment Share on other sites More sharing options...
samshel Posted July 15, 2008 Share Posted July 15, 2008 pl mark it solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.