Forum Moderators: coopster

Message Too Old, No Replies

mail script errors

Warning: Unexpected/ Parse error: parse error,

         

firstodd

7:02 pm on Jun 19, 2007 (gmt 0)

10+ Year Member



Hello,

I am trying to do a little php script to send a form from the .htm

On hitting the submit button, I'm getting this:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/content/f/i/r/firstodd/html/contact.php on line 3

Parse error: parse error, unexpected T_VARIABLE in /home/content/f/i/r/firstodd/html/contact.php on line 4

--

I'm don't know anything about this stuff, I'm just modifying a guide showing how to do it. Here is the .php down to the 4th line.. modified to not reveal information:

<?php
$to = "email@example.net";
$subject = "Subject";
$applicant first name = $_REQUEST['applicant first name'] ;

and there is about 50-100 lines similar before it ends, one for each <input .

Any insight?

[edited by: eelixduppy at 7:02 pm (utc) on June 19, 2007]
[edit reason] example.net [/edit]

firstodd

6:13 pm on Jun 29, 2007 (gmt 0)

10+ Year Member



hmm

With what you posted I'm getting these in the sent email:

MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="==Multipart_Boundary_xa0070e66668734c9b0b920253acf699cx"

==Multipart_Boundary_xa0070e66668734c9b0b920253acf699cx
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

First Name: firstodd
Last Name:
Email: email@email.net
Enquiry:

==Multipart_Boundary_xa0070e66668734c9b0b920253acf699cx
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<html>
<body>
<strong>First Name:</strong> firstodd
<strong>Last Name:</strong>
<strong>Email:</strong> email.email.net
<strong>Message:</strong>
</body>
</html>

==Multipart_Boundary_xa0070e66668734c9b0b920253acf699cx

The only address that's receiving the emails I know accepts html, I don't think the plain alternative is necessary. I would say maybe my webmail just doesn't accept html, but I've got some fancy message right under it with bolds, pics, etc.

Could you maybe just give me the adjusted header for the loop version, that would work fine. I tried mixing in the header from the script you listed here matt, but it was just my guesswork.

mattclayb

2:05 pm on Jun 30, 2007 (gmt 0)

10+ Year Member



your mail configuration may not accept injected headers, this is why they get forced into the body of the email.

You can try one of these two methods, that will send only an encoded html email.

The first method is using the manually constructed html email as I mentioned. The second method using the loop.

-------------FIRST------------

<?PHP

$subject = "Your email subject";
$mailto = "youremail@yourdomain.com";
$from = "fromemail@domain.com";

//unique boundary id
$boundary = uniqid("HTMLEmail");

//begin headers
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";

//HTML version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("<html>
<body>
<p>
<strong>First Name:</strong> $fname <br />
<strong>Last Name:</strong> $lname <br />
<strong>Email:</strong> $email <br />
<strong>Message:</strong> $enquiry <br />
</p>
</body>
</html>
"));

//send

mail("$mailto", "$subject", "", $headers);

?>

-------------SECOND-------------

<?PHP

$message = '';
foreach ($_POST as $key => $value) {
$message .= '<strong>' . $key . '</strong>: ' . $value . "<br>\n";
}

//unique boundary id
$boundary = uniqid("HTMLEmail");

//begin headers
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";

$mailto = "youremail@yourdomain.com";
$subject = "Enquiry from site";
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("<html>
<body>
$message
</body>
</html>
"));

mail("$mailto", "$subject", "", $headers);

?>

firstodd

10:57 pm on Jul 2, 2007 (gmt 0)

10+ Year Member



Okay,

It's working fine now, all 50 or so fields are coming through with no errors.

I was getting some kind of error about the mail( function trying to integrate the html. Tried to figure it out guess and checking but no success.

I made all of the Posts capital, so it's the same effect as bold to an extent. Looks okay, will work.

Thanks for all the help guys, sorry for the wordpad thing, now i know.

Tyler

This 33 message thread spans 2 pages: 33