Jump to content

Help with displaying text


JSHINER

Recommended Posts

When I use

 

echo <<<END $field END;

 

It displays this example:

 

------------------

 

Text "goes" here.

 

More text.

 

-------------------

 

LIKE THIS

 

-------------------

 

Text \"goes\" here. More text.

 

-------------------

 

Is there anything I can do to fix this?

Link to comment
https://forums.phpfreaks.com/topic/38182-help-with-displaying-text/
Share on other sites

Ok that works for displaying on the page. But when the user hits NEXT to send to me (I receive via email) ...

 

If I type in the form --- Testing "test"

 

 

All I get in the email from the user is --- Testing \

 

This is what sends the information to me:

 

----------------------

 

msgtxt = "

 

$field1

$field2

 

";

 

$header = "To: ".$order_email."\n";

$header .= "From: ".$order_email."\r\n";

$mailresult  = @mail("",$subject,$msgtxt,$header);

 

----------------------

 

How can I make it so the $field1 will send ALL info regardless of whether or not there are " or ' in it.

 

 

Any help is much appreciated!

 

 

Thanks!

Here you go a little gift.

 

 

<?php

$email_address="what the email address is ?";

$to = $email_address;

$subject = 'what the subject is ?';

$message = '<html><body>
<table align='center'><tr><td align='center'>
The message here
</tr></td></table></body></html>;

$your_email_address="your email";

$headers = "From: $your_email_address\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
if(mail($to, $subject, $message, $headers)){

echo " your mail was sent";
exit;

}else{

echo "  no mail sent"; 
exit;
}


?>

Thank you - That works great EXCEPT

 

 

I have a form - lets call the "your message" field "field1"

 

When I put for a message in field1 (scrolling text box)

 

-------------------

 

This is a test

 

It isn't "working" yet.

 

-------------------

 

I use: $field1s = stripslashes(nl2br($field1));

 

I have it added to the $message = as '.$field1s.'

 

I get this as an email:

 

-------------------

 

This is a test

 

It isn\'t

 

--------------------

 

It adds \ in front of all ' and does not display anything in " " or after them.

 

 

Any help would be much appreciated..

It is a bit lenghty, so I wont paste it all - but I have a form that asks for a few fields, one of them being "desc" which is a scrolling text box. When you click submit, it goes to a "Preview" page where it displays the form results to be checked, with another form using hidden fields, one being:

 

<input type="hidden" name="desc" value="'.$desc.'">

 

When you click submit on the preview page, it finally goes here:

 

$email_address = "[email protected]";

$to = $email_address;

$subject = 'NEW SIGN UP';

$descfin = stripslashes(nl2br($desc));

$message = '<html><body>
<table align=center><tr><td align=center>
'.$descfin.'
</tr></td></table></body></html>';

$your_email_address="[email protected]";

$headers = "From: $your_email_address\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";
       
if(mail($to, $subject, $message, $headers)){

 

Okay try this and let me know what you get:

$to = '[email protected]';
$subject = 'NEW SIGN UP';

if(get_magic_quotes_gpc()){
$descfin = stripslashes(nl2br($_POST['desc']));
}else{
$descfin = nl2br($_POST['desc']);
}


$message = "<html><body>$descfin</body></html>";

$from = '[email protected]';

$headers = "From: $from\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";
       
mail($to, $subject, $message, $headers);

Are you adding slashes anywhere via mysql_real_escape_string or addslashes()?

 

Change the if statement I wrote to just this:

$descfin = stripslashes(nl2br($_POST['desc']));

 

I know it's what you had before, but since we changed the quotes on the email maybe that helped... *shrug*

Ok we got the isn\'t problem fixed. Still kills anything in " " and after.

 

This isn't working - displays fine.

 

This isn't "working" - only displays: This isn't

 

1 down, 1 to go.

 

Any suggestions?

 

 

Thanks again for all the help. I reall appreciate it.

When I add another field such as:

 

$message = "<html><body>$descfin<br>$category</body></html>";

 

And enter:

 

------------------

 

$desc =

 

This is a "test"

 

It isn't working

 

$category =

 

Test Cat

 

------------------

 

The email I get is:

 

------------------

 

This is a

Test Cat

 

------------------

 

So the problem is in the $desc - It does not completely kill the message - just the text inside of an after " " in $desc.

 

Really weird. Never seen this problem before.

 

Any suggestions would be much appreciated . . . I am stuck.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.