/    Sign up×
Community /Pin to ProfileBookmark

using the mail function

i know how to send a simple mail msg with
<?php mail(‘[email protected]‘,$_POST[‘subject’],$_POST[‘body’]);
?>

but i have a form that has about 12 text boxes and i want to send them in a email to an address but have it nicly formated can i use

<?php mail(‘[email protected]‘,$_POST[‘subject’],$_POST[‘body’],$_POST[‘body2’],$_POST[‘body4’]POST[‘body4’]);
?>

if that works will it come out one long line in the email?

what other ways can i do this?

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@schizoOct 22.2004 — You can put linebreaks in yourself if you want...

<i>
</i>&lt;?
$bodyText = $_POST["body1"]."n".$_POST["body2"]."n".$_POST["body3"];

<i> </i>mail("[email protected]", $_POST["subject"], $bodyText);
?&gt;


Or just use HTML formatting between each body post var.
Copy linkTweet thisAlerts:
@Ne__uSauthorOct 22.2004 — <?

$bodyText = $_POST["lastname"]."n".$_POST["firstname"]."n".$_POST["address"]."n".$_POST["city"]."n".$_POST["province"]."n".$_POST["postal"]."n".$_POST["postal2"]."n".$_POST["hphone"]."n".$_POST["wphone"]."n".$_POST["cphone"]."n".$_POST["email"]."n".$_POST["unit"]."n".$_POST["howlong"]."n".$_POST["when"]."n".$_POST["movingsupplies"]."n".$_POST["comments"];



mail('[email protected]','Reservations Form','$bodytext');

?>


what is wrong with this code? all i get in a email body is $bodytext

is it case sensitive?
Copy linkTweet thisAlerts:
@schizoOct 22.2004 — Remove the single quotes around $bodytext since it's a variable, not a string.

<i>
</i>mail('[email protected]','Reservations Form',$bodyText);


Also, you should keep the cases the same. If you declare it as bodyText, send it as bodyText.
Copy linkTweet thisAlerts:
@drythirstOct 23.2004 — What the heck is n???
Copy linkTweet thisAlerts:
@schizoOct 23.2004 — It's the PHP newline character. AKA "hard return".
Copy linkTweet thisAlerts:
@drythirstOct 23.2004 — ? ? It never works for me...

I just see like Blah blah blah n n n n blah blah blah blah[/quote]
its so annoying...
Copy linkTweet thisAlerts:
@Paul_JrOct 23.2004 — [i]Originally posted by drythirst [/i]

[B]:confused: :confused: It never works for me...
I just see like

its so annoying... [/B][/QUOTE]

Is it enclosed in double-quotes? If it's not enclosed within double-quotes, then it will just be spit out as "n", rather than a new line.
Copy linkTweet thisAlerts:
@drythirstOct 23.2004 — Nope, it never was. I did't know it had to be...

so its gotta be:
[code=php]
<?php
#stuff
echo (Blah blah blah "n""n""n""n""n" blah blah blah);
#more stuff
?>
[/code]

Cool! Well, at least I didn't write the code; Jonathan (Jona) made it for me lol (well not really me that he wrote it for)
Copy linkTweet thisAlerts:
@Paul_JrOct 23.2004 — [i]Originally posted by drythirst [/i]

[B]Nope, it never was. I did't know it had to be...

so its gotta be:

[code=php]
<?php
#stuff
echo (Blah blah blah "n""n""n""n""n" blah blah blah);
#more stuff
?>
[/code]

Cool! Well, at least I didn't write the code; Jonathan (Jona) made it for me lol (well not really me that he wrote it for) [/B][/QUOTE]

Well, it doesn't actually need to be in its own set of double-quotes, just any double-quotes, as long as they are double-quotes. ?
Copy linkTweet thisAlerts:
@EupseudesOct 26.2004 — Plus, if you wanted to do that, you'd have to cocecatenate the strings by putting a "." between them

[code=php]echo "n"."n"."n";[/code]

But that, as Paul Jr mentioned before, doesn't need it's own quotations

[code=php]echo "nnn";[/code]
×

Success!

Help @Ne__uS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...