send html email form html form

help me

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 2377 Views - Last Post: 12 June 2008 - 01:53 AM Rate Topic: -----

#1 we_undertaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 06-May 08

send html email form html form

Posted 11 June 2008 - 04:50 AM

<html><body><font face=Arial size=2> 

<form method="post" action="contact.php"> 

<table bgcolor=#ffffcc align=center> 
<tr><td colspan=2><strong>Contact us using this form:</strong></td></tr> 


<tr><td>To:</td><td><input size=25 name="sendto"></td></tr> 
<tr><td><font color=red>*</font> From:</td><td><input size=25 name="Email"></td></tr> 


<tr><td><font color=red>*</font> Name:</td><td><input size=25 name="Name"></td></tr> 
<tr><td><font color=red>*</font> Image:</td><td><IMG SRC="http://mecamanhyeuem.10giay.us/Blue_hills.jpg" height="200" width="200" name="Image"></td></tr>

<tr><td colspan=2>Message:</td></tr> 
<tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr> 

<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr> 
<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr> 
</table> 
</form> 
</body> 
</html> 



this is my process for sending

<html>
<body><font face=Arial size=2>

<?php 
$to = $_REQUEST['sendto']; 
$from = $_REQUEST['Email']; 
$name = $_REQUEST['Name']; 
$headers = "From: $from";

$subject = "Web Contact Data"; 

$fields = array();

$fields{"Image"} = "Image";
$fields{"sendto"} = "sendto"; 
$fields{"Name"} = "Name"; 
$fields{"Company"} = "Company"; 
$fields{"Email"} = "Email"; 
$fields{"Phone"} = "Phone"; 
$fields{"list"} = "Mailing List"; 
$fields{"Message"} = "Message"; 



$body = "We have received the following information:\n\n";
	foreach($fields as $a => $b) {$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

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

//$headers2 = "From: noreply@YourCompany.com"; 
//$subject2 = "Thank you for contacting us"; 
//$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";

if($from == '') {print "You have not entered an email, please go back and try again";} 
else { 
if($name == '') {print "You have not entered a name, please go back and try again";} 
else { 
$send = mail($to, $subject, $body, $headers); 
//$send2 = mail($from, $subject2, $autoreply, $headers2); 
if($send) 
{print "thank you";} 
else 
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; } 
}
}
?> 
</body> 
</html> 



- the process for sending is working , and i receive a email .
but the thing is that, the image is not display in email
so i think should use the hml email , so that the image will display..
any one help me how to send a html email

Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: send html email form html form

#2 rjolitz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 110
  • Joined: 17-May 08

Re: send html email form html form

Posted 11 June 2008 - 07:07 AM

View Postwe_undertaker, on 11 Jun, 2008 - 04:50 AM, said:

- the process for sending is working , and i receive a email .
but the thing is that, the image is not display in email
so i think should use the hml email , so that the image will display..
any one help me how to send a html email

Thank you


I may be wrong, but I don't see where you are passing the image to the contact.php to be processed. It is in the table, but not passed as a value to your .php file.

That, and when I tried to pull up the image link it is a broken link and no image shows up.


You are also setting up space in your array for the image but it appears to have no value.

Try fixing that and post up some new code :)
Was This Post Helpful? 0
  • +
  • -

#3 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: send html email form html form

Posted 11 June 2008 - 12:55 PM

You need to link to the image on your site, not include the actual image in the e-mail. Just use a basic <img> tag. That'll display the image properly. Let me know if that solves your problem.
Was This Post Helpful? 0
  • +
  • -

#4 silverblaze  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 69
  • Joined: 18-January 08

Re: send html email form html form

Posted 11 June 2008 - 01:16 PM

hey we_undertaker,

as akozlik said ordiany <img></img> tag will display the images in mail.

bt in ur script wht
<tr><td><font color=red>*</font> Image:</td><td><IMG SRC="http://mecamanhyeuem.10giay.us/Blue_hills.jpg" height="200" width="200" name="Image"></td></tr>


this code do is that it will just display the picture, not sending it to the php page. i see its an static image, if u want to sent the same image to every one u can hardcode the image url into the php page or other wise fetch it frm a db. or if really want to sent it form the form use a hidden feild to sent the link into the php page.

more over in the body too it will just display
 image: <imageurl> 
even after u sent the imageurl. u need to use the <img> tag. coz of this
foreach($fields as $a => $b) {$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }


And one more advice,
$from = $_REQUEST['Email'];
$headers = "From: $from";



never ever use it like this, this is a huge security hole, users can sent spam messages frm your server using this.

think wht if they enter in the email feild the following as email address

someemail@xx.com\nBCC: someotheremail.yy.com, anotheremail@zz.com

so use a regular expression to aviod such a big mistake.

hope it helps. plz let us know.

take care.

This post has been edited by silverblaze: 11 June 2008 - 01:19 PM

Was This Post Helpful? 0
  • +
  • -

#5 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: send html email form html form

Posted 11 June 2008 - 03:15 PM

Quote

someemail@xx.com\nBCC: someotheremail.yy.com, anotheremail@zz.com

so use a regular expression to aviod such a big mistake.

take care.


Well Regex might not be the best way to validate that data. You typically use regexes to look for patterns in data, though I guess you could use them in that instance.

That reminds me of people using $_GET in their sql queries.

$sql = "insert into users (usename, password) values ('$_GET['username']', '$_GET['password'])";

You're just opening yourself up to a whole slew of security issues.

Posted Image

This post has been edited by akozlik: 11 June 2008 - 03:15 PM

Was This Post Helpful? 1
  • +
  • -

#6 we_undertaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 06-May 08

Re: send html email form html form

Posted 11 June 2008 - 06:45 PM

got try some way but still can't
anyone can provide me the code , that i can send html email which have image ... thank you
Was This Post Helpful? 0
  • +
  • -

#7 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: send html email form html form

Posted 11 June 2008 - 06:51 PM

for the body of the email, when you put in the message, just add the html code for the image, IE: <img src=1.php>
Was This Post Helpful? 0
  • +
  • -

#8 we_undertaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 06-May 08

Re: send html email form html form

Posted 11 June 2008 - 06:55 PM

but the form come from html, and sending by paging.php for process, can u explain more a bit , cos i just new in php
Was This Post Helpful? 0
  • +
  • -

#9 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: send html email form html form

Posted 11 June 2008 - 07:07 PM

$body = "We have received the following information:\n\n";
    foreach($fields as $a => $B)/> {$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }



just make it this:
$body = "We have received the following information:\n\n";
    foreach($fields as $a => $B)/> {$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]."<img src=".$image_location.">"); }



not the part where the img src is.... you may want to change it, since right now it would add an image each time it goes through....
Was This Post Helpful? 0
  • +
  • -

#10 we_undertaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 06-May 08

Re: send html email form html form

Posted 11 June 2008 - 07:31 PM

can anyone provide me a full code, cos i did it , but the process become while page ... plzz , thank you so much
Was This Post Helpful? 0
  • +
  • -

#11 silverblaze  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 69
  • Joined: 18-January 08

Re: send html email form html form

Posted 11 June 2008 - 09:10 PM

hey akozlik, if regex is nt a gud way to do it, then wht is? wht i did is i removed all the spl charaters like \n\r\t etc nd inserted a null charater.

nd abt the code i think this might help u
<html><body><font face=Arial size=2> 

<form method="post" action="contact.php"> 

<table bgcolor=#ffffcc align=center> 
<tr><td colspan=2><strong>Contact us using this form:</strong></td></tr> 


<tr><td>To:</td><td><input size=25 name="sendto"></td></tr> 
<tr><td><font color=red>*</font> From:</td><td><input size=25 name="Email"></td></tr> 


<tr><td><font color=red>*</font> Name:</td><td><input size=25 name="Name"></td></tr> 
<tr><td><font color=red>*</font> Image:</td><td><IMG SRC="http://mecamanhyeuem.10giay.us/Blue_hills.jpg" height="200" width="200" name="Imagedisplay">
<input type="hidden" name="Image"  value="http://mecamanhyeuem.10giay.us/Blue_hills.jpg"></td></tr>

<tr><td colspan=2>Message:</td></tr> 
<tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr> 

<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr> 
<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr> 
</table> 
</form> 
</body> 
</html> 



n the php code
<html>
<body><font face=Arial size=2>

<?php 
$to = $_REQUEST['sendto']; 
$from = $_REQUEST['Email']; 
$name = $_REQUEST['Name']; 
$headers = "From: $from";

$subject = "Web Contact Data"; 

$fields = array();

$fields{"Image"} = "Image";
$fields{"sendto"} = "sendto"; 
$fields{"Name"} = "Name"; 
$fields{"Company"} = "Company"; 
$fields{"Email"} = "Email"; 
$fields{"Phone"} = "Phone"; 
$fields{"list"} = "Mailing List"; 
$fields{"Message"} = "Message"; 



$body = "We have received the following information:\n\n";
	foreach($fields as $a => $b) {
	  if($b == 'Image'){
		  $body .= "Image: <img src=".$_REQUEST[$a]." height='200' width='200' />";
	  }
else{
$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
}


if($from == '') {print "You have not entered an email, please go back and try again";} 
else { 
if($name == '') {print "You have not entered a name, please go back and try again";} 
else { 
$send = mail($to, $subject, $body, $headers); 

if($send) 
{print "thank you";} 
else 
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; } 
}
}
?> 
</body> 
</html> 



hope this will work. :)
plz let us kne.

take care.
Was This Post Helpful? 0
  • +
  • -

#12 we_undertaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 06-May 08

Re: send html email form html form

Posted 11 June 2008 - 10:03 PM

hi silverblaze,
i make a test , but in the email , its not a html email , just a text email

in my email :
We have received the following information:

Image: <img src=http://mecamanhyeuem.10giay.us/Blue_hills.jpg height='200' width='200' />			  


				Name: dreamcode
				Email: alo@yahoo.com
			   Message: 1235 1235 1235


Was This Post Helpful? 0
  • +
  • -

#13 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: send html email form html form

Posted 11 June 2008 - 11:47 PM

You aren't setting the header type to html, that's why it's not being processed. The code should look like this

<html>
<body><font face=Arial size=2>

<?php
$to = $_REQUEST['sendto'];
$from = $_REQUEST['Email'];
$name = $_REQUEST['Name'];
$headers = "From: $from\n" . 
                  "MIME-Version: 1.0\n" .
                  "Content-type: text/html; charset=iso-8859-1";

$subject = "Web Contact Data";

$fields = array();

$fields{"Image"} = "Image";
$fields{"sendto"} = "sendto";
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";



$body = "We have received the following information:\n\n";
    foreach($fields as $a => $B)/> {
      if($b == 'Image'){
          $body .= "Image: <img src=".$_REQUEST[$a]." height='200' width='200' />";
      }
else{
$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
}


if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);

if($send)
{print "thank you";}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?> 



Notice that I added the text/html and header information. When you send that, it'll go. Try to utilize google to find tutorials on what you're trying to do if you can't find a tutorial here. It took about 2 minutes to pull up a great tutorial.

Here's the link

We on the DIC board won't typically write your code for you. We need to make sure that we see the work you've done, and then we'll assist you from there. Let us know if this modified script helps solve your problem.

View Postsilverblaze, on 12 Jun, 2008 - 12:10 AM, said:

hey akozlik, if regex is nt a gud way to do it, then wht is? wht i did is i removed all the spl charaters like \n\r\t etc nd inserted a null charater.


I guess regex would work if you wrote a good enough e-mail validation. You could simply strip all the slashes from the e-mail field and send it out like that. It would just bounce back with an invalid e-mail address. Probably not the most graceful, but it'd work. Either way would work though. I think you're onto something with stripping the whitespace. That'd make everything run together and make a bad e-mail address.
Was This Post Helpful? 0
  • +
  • -

#14 silverblaze  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 69
  • Joined: 18-January 08

Re: send html email form html form

Posted 12 June 2008 - 12:12 AM

Oops!! i forget the header. Im really sry abt that. :(

hmm.. hey akozlik is thr ny way other than regex. i mean more effective n efficient way.
Was This Post Helpful? 0
  • +
  • -

#15 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: send html email form html form

Posted 12 June 2008 - 12:26 AM

View Postsilverblaze, on 12 Jun, 2008 - 03:12 AM, said:

Oops!! i forget the header. Im really sry abt that. :(

hmm.. hey akozlik is thr ny way other than regex. i mean more effective n efficient way.


Not that I can think of. I went back and rethought my original post, and I think I was on coke. I don't see why regexes wouldn't work. I think I was just being a poop stain, sorry about that.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2