954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can you make this word wrap?

Hey folks,

Anyone know how to take the code below and make sure that all the stuff that gets sent to the email wordwraps at 400 pixels? Please HELP!

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

session_start();
if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
$message = wordwrap($message, 70); 
mail("rbeale@bealeinc.com,iam1az@cox.net","Membership Application","Form data:

First Name: " . $_POST['field_1'] . " 
Last Name: " . $_POST['field_2'] . " 
Your Email Address: " . $_POST['field_3'] . " 
Street Address: " . $_POST['field_4'] . " 
City: " . $_POST['field_5'] . " 
State: " . $_POST['field_6'] . " 
Zip Code: " . $_POST['field_7'] . " 
Home Phone: " . $_POST['field_8'] . " 
Work Phone: " . $_POST['field_9'] . " 
Cell Phone: " . $_POST['field_10'] . " 
Name of Emergency Contact: " . $_POST['field_11'] . " 
Phone of Emergency Contact: " . $_POST['field_12'] . " 
Relationship To You: " . $_POST['field_13'] . " 
Brief History of Yourself: " . $_POST['field_14'] . " 
Make of Motorcycle You Own: " . $_POST['field_15'] . " 
Model of Motorcycle you Own: " . $_POST['field_16'] . " 
Year of Motorcycle You Own: " . $_POST['field_17'] . " 
Years of Riding Experience: " . $_POST['field_18'] . " 
State Reason For Joining: " . $_POST['field_19'] . " 



 
");

include("confirm.html");
}
else {
echo "Invalid Captcha String.";
}

?>


Thanks

Benjamin

benjamindemers
Newbie Poster
4 posts since Oct 2008
Reputation Points: 9
Solved Threads: 0
 

While you can wrap at a certain amount of characters in plain text emails, I'm not certain about the ability to wrap at exactly 400 pixels.

What you can do is send and html email instead, and put the text inside a container that is set to 400 pixels wide.

scru
Posting Virtuoso
1,629 posts since Feb 2007
Reputation Points: 975
Solved Threads: 140
 

Here is a thread on wordwrap if you decide to go that direction:
http://www.daniweb.com/forums/thread151130.html

R0bb0b
Posting Shark
998 posts since Jun 2008
Reputation Points: 358
Solved Threads: 89
 

Hey folks,

Anyone know how to take the code below and make sure that all the stuff that gets sent to the email wordwraps at 400 pixels? Please HELP!

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

session_start();
if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
$message = wordwrap($message, 70); 
mail("rbeale@bealeinc.com,iam1az@cox.net","Membership Application","Form data:

First Name: " . $_POST['field_1'] . " 
Last Name: " . $_POST['field_2'] . " 
Your Email Address: " . $_POST['field_3'] . " 
Street Address: " . $_POST['field_4'] . " 
City: " . $_POST['field_5'] . " 
State: " . $_POST['field_6'] . " 
Zip Code: " . $_POST['field_7'] . " 
Home Phone: " . $_POST['field_8'] . " 
Work Phone: " . $_POST['field_9'] . " 
Cell Phone: " . $_POST['field_10'] . " 
Name of Emergency Contact: " . $_POST['field_11'] . " 
Phone of Emergency Contact: " . $_POST['field_12'] . " 
Relationship To You: " . $_POST['field_13'] . " 
Brief History of Yourself: " . $_POST['field_14'] . " 
Make of Motorcycle You Own: " . $_POST['field_15'] . " 
Model of Motorcycle you Own: " . $_POST['field_16'] . " 
Year of Motorcycle You Own: " . $_POST['field_17'] . " 
Years of Riding Experience: " . $_POST['field_18'] . " 
State Reason For Joining: " . $_POST['field_19'] . " 



 
");

include("confirm.html");
}
else {
echo "Invalid Captcha String.";
}

?>

Thanks

Benjamin

I think you have misunderstood what I wanted or don't know how to do this. It should be simple for someone who knows php to come up with a fix on this code to make the email it generates word wrap.

To restate: I want this code that sends an email to have the results that it generates within the email WORD WRAP at 100 characters including spaces.

HELP!

benjamindemers
Newbie Poster
4 posts since Oct 2008
Reputation Points: 9
Solved Threads: 0
 

Take a look at the wordwrap function in PHP:
http://uk.php.net/wordwrap

wordwrap($text, 100, "\n", true);
Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

So are you saying that I have to define the text that is wrapped before it will wrap it? In this case the input variables are always different. They are putting in things like address and reasons for joining. These will never be constant.

What do you do in the case listed above to make an unknown variable text wordwrap at such and such column width? Please use the php exactly as listed.

Excellent resource by the way this PHP library. Problem is I don't know PHP yet. I want to learn it but I have this pressing problem that needs solving now.

Please continue to help me figure this out.

Benjamin

benjamindemers
Newbie Poster
4 posts since Oct 2008
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You