Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Email form trouble!!!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Email form trouble!!!

Postby SOLID » Tue Oct 08, 2002 6:59 pm

Hi everyone
Im trying to reuse a email script, and all is working well BUT the textarea boxes are not holding there line breaks??
im new to PHP so could someone show me why its doing this

heres the code

<?php
function file2go2($url){ print "<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"0;URL=$url\">\n</head>\n</html>"; exit; }

if(!@fopen($F_TEMPLATE, "r")) file2go2($F_NOTSENT);
else $arr_t1 = @file( $F_TEMPLATE ); $nr_mail = 1;
if (! $F_TEMPLATE2 == "" && !@fopen($F_TEMPLATE2, "r")) file2go2($F_NOTSENT);
if (! $F_TEMPLATE2 == "" && @fopen($F_TEMPLATE2, "r")) $arr_t2 = @file( $F_TEMPLATE2 ); $nr_mail = 2;

$domail = 1;
while ($domail <= $nr_mail):
if ($domail == 1) $var2use = $arr_t1; else $var2use = $arr_t2;

for ($index = 0; $index < count($var2use); $index++)
{
$pattern = ereg("\{\{[A-z0-9_]*\}\}", $var2use[$index]);


if ($pattern)
{
$line = ereg_replace("\{\{","$",$var2use[$index]);
$line = ereg_replace("\}\}","",$line);
}
else
{
$line = $var2use[$index];
}
$line = addslashes($line) . "<br>";
eval( "\$line = \"$line\";" );
if ($index == 0 && $domail == 1) $linetot1 = $line;
elseif ($index > 0 && $domail == 1) $linetot1 .= $line;
if ($index == 0 && $domail == 3) $linetot3 = $line;
elseif ($index > 0 && $domail == 3) $linetot3 .= $line;
if ($index == 0 && $domail == 2) $linetot2 = $line;
elseif ($index > 0 && $domail == 2) $linetot2 .= $line;
}

++$domail;

endwhile;


//the next line will email the template to $F_TO of your form (normally yourself c.q. the owner of website
$mailit1 = @mail($F_TO, $F_SUBJECT, $linetot1, "From: $F_FROM \nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit");

$mailit3 = @mail($F_CC, $F_SUBJECT, $linetot1, "From: $F_FROM \nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit");

//the next line will email the sender: change the $email to the variable of your form (the email adress of the visitor)
//only do this when you want 2 templates emailed.
if ($nr_mail == 2) $mailit2 = @mail($cc, $F_SUBJECT, $linetot2, "From: $F_FROM\nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit");

if ($mailit1 = true) $sent = 1;
else $sent = 0;

if ($mailit3 = true) $sent = 3;
else $sent = 0;

if ($mailit2 = true) $sent = 2;
else $sent = 0;

if ($nr_mail == 1 && $sent == 1) file2go2($F_SENT);
if ($nr_mail == 1 && $sent == 0) file2go2($F_NOTSENT);
if ($nr_mail == 3 && $sent == 3) file2go2($F_SENT);
if ($nr_mail == 3 && $sent == 0) file2go2($F_NOTSENT);
if ($nr_mail == 2 && $sent == 2) file2go2($F_SENT);
if ($nr_mail == 2 && $sent == 0) file2go2($F_NOTSENT);
?>


Please help me :wink:
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

Postby Jay » Wed Oct 09, 2002 3:39 am

If you're having a problem with one specific part of your script, please only post the relevant code. We don't need all of it!

Anyway, to make a new line in a form text area you need to use the HTML entity which is something like &10; (i'm using a bloody mac at the moment which doesn't have a hash key, so you'll have to search for it because I've posted it quite a few times)
Jay
 

I dont understand

Postby SOLID » Wed Oct 09, 2002 4:32 pm

Hi Jay
Im a newbie to PHP, sorry for putting the whole script but i dont know which bits are doing what?

with the &10; how do i do this ? is it manually inserted into the text area or in the code.. id prefer if it was not input by the end user??

Please help me!!!!!! :?
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

FIXED IT!!!!!!

Postby SOLID » Wed Oct 09, 2002 8:43 pm

:D
Hi All
found the problem, it was in the mail part of the script>

THIS>>
$mailit1 = @mail($F_TO, $F_SUBJECT, $linetot1, "From: $F_FROM \nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit");

SHOULD BE THIS>>
$mailit1 = @mail($F_TO, $F_SUBJECT, $linetot1, "From: $F_FROM");

Thanks all
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

Re: I dont understand

Postby Jay » Wed Oct 09, 2002 11:17 pm

SOLID wrote:with the &10; how do i do this ? is it manually inserted into the text area or in the code.. id prefer if it was not input by the end user??

&#10; is the HTML equivilent for a newline character, if you want it to appear as a new line. When a user enters a new line, it will be sent to your script as a \n, but the convert it back to have to convert it to &#10; to make it display a newline. No user intervention is required.
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron