...

View Full Version : HTML in forms



HackSawed
05-08-2006, 12:59 PM
okay so i have a form located @ http://bigfooty.hacksawed.com/email.html

this form basically gets data and posts it to another page called submit.php

submit.php then emails our email at hacksawed@gmail.com

the problem is, i want to allow it to send html rather than text, and for that html to be displayed accordingly (like a website) in our email account.

the code for email.html is:


<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Anonymous Email Sender</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="submit.php">
<label>Subject:
<input type="text" name="textfield" />
</label>
<p>
<label>Message
<textarea name="textarea" cols="100" rows="20"></textarea>
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
</form>
</body>
</html>


The code for submit.php is:


<?php
# ----------------------------------------------------
# -----
# ----- This script was generated by the demo version of PHP-Form 1.1 on 8/05/2006 at 7:59:15 PM
# -----
# ----- http://www.websitedatabases.com
# -----
# ----------------------------------------------------
# -----
# ----- Many Features are available only in the Full version, to order please follow this link :
# -----
# ----- http:// www.websitedatabases.com/form-form/index.html
# -----
# ----------------------------------------------------


// Receiving variables
@$textfield = addslashes($_POST['textfield']);
@$textarea = addslashes($_POST['textarea']);

// Validation
//Sending Email to form owner
# Email to Owner
$pfw_header = "From: bigfooty@gmail.com";
$pfw_subject = "#textfield#";
$pfw_email_to = "hacksawed@gmail.com";
$pfw_message = "$textarea\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

header("Location: login.html");

?>


im not sure which file to edit, i think its email.html, but im nto sure.

can anyoen help???

jonnybinthemix
05-08-2006, 01:15 PM
theres no real difference between text emails and html emails, its just the way the client interprets the text.

Just add a content type header:


$headers = "Content-type: text/html\r\n";

Try that..

Jon

HackSawed
05-08-2006, 02:11 PM
unfortunately it didnt work. i added it here:

$headers = "Content-type: text/html\r\n";
$pfw_header = "From: bigfooty@gmail.com";
$pfw_subject = "#textfield#";
$pfw_email_to = "hacksawed@gmail.com";
$pfw_message = "$textarea\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

which code do it add it to, and where in the code do i add it?

i got it to send the email both to a hotmail account and gmail account, and both spat it out as coding rather than what its sposed to do, and i know that both these email companies do html.

jonnybinthemix
05-08-2006, 05:02 PM
theres no use in creating a var unless your going to use it


$headers = "Content-type: text/html\r\n";
$pfw_header = "From: bigfooty@gmail.com";
$pfw_subject = "#textfield#";
$pfw_email_to = "hacksawed@gmail.com";
$pfw_message = "$textarea\n";

mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header, $headers ) ;

Try that, see what happens...

Jon

HackSawed
05-08-2006, 07:29 PM
i think we are on the right track, but the server gives me this error:


Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.33 Server at bigfooty.hacksawed.com Port 80

And I know its not to do with the server, becuase I reedited it back and the email went thru (just obviously with the problem i had before there).

jonnybinthemix
05-08-2006, 09:28 PM
This should get you closer, (hopefully), see how you get on with that, add the other bits and pieces you want.



$to = "hacksawed@gmail.com";
$from = "$_POST['fromfield'];
$subject = "$_POST['subject'];
$message = "$_POST['messaqe'];
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";

mail($to, $subject, $message, $headers);

Thats all off the top of my head, so may need a bit of work, but should get you closer to your goal!! :)

Jon

HackSawed
05-09-2006, 08:32 AM
I then get this problem:


Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/h/a/c/hacksawed/html/bigfooty/sub.php on line 25

jonnybinthemix
05-09-2006, 03:37 PM
can you copy your whole script?

that will make it easier.

Jon

EDIT/ i dident look above!!

jonnybinthemix
05-09-2006, 04:21 PM
Tested and working, just add your email and should be ok....

Form:


<html>
<head>
<title>Email</title>
<style type="text/css">

</style>
</head>
<body>

<form name="mail" method="post" action="mail.php">

Your Name:<br>
<input type="text" name="name" value="Your name..." size="20"><br>
<br>
Subject: <br>

<input type="text" name="subject" value="Subject..." size="28"><br>
<br>

Comment:<br>
<textarea rows="10" cols="25" name="comment"> </textarea><br>
<br>
<br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

</body>
</html>


and mail.php


<?php

$to="jon@fartingfish.com";
$from=$_POST['name'];
$subject=$_POST['subject'];
$message=$_POST['comment'];
$headers = "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: $from\r\n";
if (mail($to, $subject, $message, $headers))
echo "Message Sent!";
else
echo "Failed to send message.";
?>


Jon

rmedek
03-10-2007, 05:31 PM
It was brought to my attention that the HTML form needed was actually a fake VBulletin notice designed to phish information from other forum members. Regardless if it was or not, I've decided to delete any threads that followed after that code was introduced, and close this thread.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum