View Full Version : HTML E-mail form in PHP, what is wrong?

06-05-2007, 05:39 PM
So, I'm trying to implement HTML code for my E-mail sent by the PHP script so I can add in a picture (Silly, I know, but that's how they want it :/)

This is where I am so far: I've tried implementing the HTML, but it won't send e-mails anymore. Before the HTML changed, this was working... So I must have done something terribly wrong here...
this is what I've changed, if you want me to post the entire file, please ask :)

$message = "
<title>=KMD= Application</title>
<p>$todayis [EST]</p>
<p>From:$visitor ($visitormail)</p>
<p>Gamename: $gamename</p>
<p>Age: $age</p>
<p>Sex: $sex</p>
<p>Favourite class: $class</p>
<p>Experience: $exp</p>
<p>Prefered name: $prefname</p>
<p>Why we should let him in KMD: $notes</p>

<p>Additional Info : IP = $ip</p>
<p>Browser Info: $httpagent</p>
<p>Referral : $httpref</p>

$from = "From: $visitormail\r\n";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail("myemail@gmail.com", $subject, $message, $headers, $from);

I was following instructions found here: http://be.php.net/manual/nl/function.mail.php

Thanks in advance!

Oh right, I just pasted the error checking in again, and this is what I'm getting:
Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE. in /customers/ilfiorfiore.be/ilfiorfiore.be/httpd.www/kmdtest/contact3.php on line 124

Ok, so that's fixed, but I still can't add an image with <img src="" />
Any ideas?

06-05-2007, 06:34 PM
Uh the first post is getting cluttered so I'll explain myself on the second post :)

I've got it to work, but apparently <img src=" link to picture " /> doesn't work... And gives no error either, just a blank page.

Does anyone know if I could add images to my mail this way? And how?


06-05-2007, 06:58 PM
as noted by on the manual you referred to,
Note: If intending to send HTML or otherwise Complex mails, it is recommended to use the PEAR package PEAR::Mail_Mime.
which i linked to as above i believe you could add images with either way but if its not working then try the PEAR package

06-05-2007, 07:03 PM
Well I'm a beginning PHP coder... And I have no clue how to implement such a thing...
So I was kind of hoping for a very straight-forward solution to this, without having to implement sophisticated php means like that...
But thanks anyway...

If there are any other solutions, I'd love to hear them though :P

06-05-2007, 07:24 PM
Where is the rest of your code? You only seemed to post a snippet for it.

06-05-2007, 07:41 PM
Alright, here's the entire code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>

<style type="text/css">
.style1 {font-size: 12px}
.style3 {color: #643200}
.style4 {font-size: 10px;
color: #FF0000;
body {background-color:#000000;
body a {font-size: 1.1em;}
body a:visited {color:#0000CC;}

p.errinv {color:#cc0000;


<form name="Application" method="post" action="">

$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");

ini_set("display_errors", true);

if ($_POST['sendit'] != '') {
$err1 = Null;
$err2 = Null;
$err3 = Null;
$err4 = Null;
$err5 = Null;
$err6 = Null;
$err7 = Null;
$visitor = $HTTP_POST_VARS['visitor'];
if ($visitor == ''){
$err1='-Name<br />';
$visitormail = $HTTP_POST_VARS['visitormail'];
if ($visitormail == ''){
$err2='-E-Mail<br />';
$gamename = $HTTP_POST_VARS['gamename'];
if ($visitormail == ''){
$err3='-Gamename<br />';
$age = $HTTP_POST_VARS['age'];
if ($age == ''){
$err4='-Age<br />';
$prefname = $HTTP_POST_VARS['prefname'];
if ($prefname == ''){
$err5='-Prefered Name<br />';
$notes = $HTTP_POST_VARS['notes'];
if ($notes == ''){
$err6='-Why should we let you join?<br />';
$donate = $HTTP_POST_VARS['donate'];
if ($donate == ''){
$err7='-Are you able to donate?<br />';
$sex = $HTTP_POST_VARS['sex'];
$class = $HTTP_POST_VARS['class'];
$exp = $HTTP_POST_VARS['exp'];
$passcheck = $HTTP_POST_VARS['passcheck'];
$ip = $HTTP_POST_VARS['ip'];
$httpref = $HTTP_POST_VARS['httpref'];
$httpagent = $HTTP_POST_VARS['httpagent'];
$security = md5($HTTP_POST_VARS['security']);
if($passcheck != $security){
$err8='-Security code!<br />';
if ($err1!= Null or $err2!= Null or $err3!= Null or $err4!= Null or $err5!= Null or $err6!= Null or $err7!= Null or $err8!= Null){
echo '<p class="errinv">You forgot something:<br />'.$err1.$err2.$err3.$err4.$err5.$err6.$err7.$err8.'<a href="javascript:history.back()">Click here</a> to return to the form and correct it.</p><br />';

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Application";

$notes = stripcslashes($notes);

$message = "
<title>=KMD= Application</title>
<p>$todayis [EST]<br /><br />
<strong>From:</strong> $visitor ($visitormail)<br /><br />
<strong>Gamename:</strong> $gamename<br />
<strong>Age:</strong> $age<br />
<strong>Sex:</strong> $sex<br />
<strong>Favourite class:</strong> $class<br />
<strong>Experience:</strong> $exp<br />
<strong>Prefered name:</strong> $prefname<br />
<strong>Why we should let him in KMD:</strong> $notes<br />
<strong>Able to donate:</strong> $donate<br />
__________<br />

<br />
<br />
Additional Info : IP = $ip<br />
Browser Info: $httpagent<br />
Referral : $httpref</p>

$from = "From: $visitormail\r\n";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail("myemail@gmail.com", $subject, $message, $headers);

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

All fields are required to be filled in!<br /><br />

Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br />
Your Gamename:<br />
<input type="text" name="gamename" size="35" />
<br />
Your Age:<br />
<input type="text" name="age" size="2" />
<br />
Your Sex:<br />
<select name="sex" size="1">
<option value=" Male ">Male </option>
<option value=" Female ">Female </option>
<br />
Your favourite class:<br />
<select name="class" size="1">
<option value=" Engineer ">Engineer </option>
<option value=" Medic ">Medic </option>
<option value=" Field Ops ">Field Ops </option>
<option value=" Covert Ops ">Covert Ops </option>
<option value=" Soldier ">Soldier </option>
<br />
Your current XP:<br />
<select name="exp" size="1">
<option value=" Under 25,000 XP">Under 25,000 XP</option>
<option value=" 25,000 XP">25,000 XP</option>
<option value=" 30,000 XP">30,000 XP</option>
<option value=" 35,000 XP">35,000 XP</option>
<option value=" 40,000 XP">40,000 XP</option>
<option value=" 45,000 XP">45,000 XP</option>
<option value=" 50,000 XP">50,000 XP</option>
<option value=" 55,000 XP">55,000 XP</option>
<option value=" 60,000 XP">60,000 XP</option>
<option value=" 65,000 XP">65,000 XP</option>
<option value=" 70,000 XP">70,000 XP</option>
<option value=" 75,000 XP">75,000 XP</option>
<option value=" 80,000 XP">80,000 XP</option>
<option value=" 85,000 XP">85,000 XP</option>
<option value=" 90,000 XP">90,000 XP</option>
<option value=" 95,000 XP">95,000 XP</option>
<option value=" 100,000 XP">100,000 XP</option>
<option value=" 105,000 XP">105,000 XP</option>
<option value=" 110,000 XP">110,000 XP</option>
<option value=" 115,000 XP">115,000 XP</option>
<option value=" 120,000 XP">120,000 XP</option>
<option value=" 125,000 XP">125,000 XP</option>
<option value=" 130,000 XP">130,000 XP</option>
<option value=" 135,000 XP">135,000 XP</option>
<option value=" 140,000 XP">140,000 XP</option>
<option value=" 145,000 XP">145,000 XP</option>
<option value=" 150,000 XP">150,000 XP</option>
<option value=" Over 150,000 XP">Over 150,000 XP</option>
<option value=" Over 200,000 XP">Over 200,000 XP</option>
<option value=" Over 250,000 XP">Over 250,000 XP</option>
<option value=" Over 300,000 XP">Over 300,000 XP</option>
<option value=" Over 350,000 XP">Over 350,000 XP</option>
<option value=" Over 400,000 XP">Over 400,000 XP</option>
<option value=" Over 450,000 XP">Over 450,000 XP</option>
<option value=" Over 500,000 XP">Over 500,000 XP</option>
<br />
Your prefered KMD member name (e.g. =KMD=(PEPSI)):<br />
<input type="text" name="prefname" size="35" />
<br />
Why should we let you join KMD? <br />(please write a text of at least 40 words):
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
Would you be able to donate through Paypal to help keep KMD alive?<br />
Yes:<input type="radio" name="donate" value="Yes" />
No:<input type="radio" name="donate" value="No" />
<br />
<?php $integer = md5(rand(1,9));
$security = md5($security); ?>
Copy the number:
<img src="generator.php?nr=<? echo $integer; ?>" alt="random number generator" />
<input name="security" type="text" class="vak" size="1" maxlength="1" />
<input type="hidden" name="passcheck" value="<? echo $integer ?>" />
<input type="submit" name ="sendit" value="Send Application" />



So if I try to add <img src=" link " />, it just doesn't work anymore...

06-05-2007, 08:02 PM
Because you are using double quotes you need to escape them or use single quotes. The following solutions will work

<img src=\" link \" />

<img src=' link ' />

I'm suprised you didn't get any errors.

06-05-2007, 09:07 PM
Because you are using double quotes you need to escape them or use single quotes. The following solutions will work

<img src=\" link \" />

<img src=' link ' />

I'm suprised you didn't get any errors.

Wow, it works... Thanks a lot! :thumbsup:

06-06-2007, 01:01 AM
also typo here

$notes = stripcslashes($notes);

you added a c

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum