We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
little php help please; i'm stuck :(
Topic Started: Apr 4 2005, 11:15 AM (650 Views)
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Hey,
for a website I'm making, I made a mailingform, and it has to create newlines in the mail that is being sent.

Right now, I use:

Code: HTML
 
<?php
if(isset($_POST["mail"])){
$overige = stripslashes($_POST["overig"]);
$overige = htmlspecialchars($overige);
$overige = nl2br($overige);
$afzender = $_POST["mail"];
$onderwerp = "Boeking aanvraag";
$inhoud = "Naam:" . $_POST["naam"];
$inhoud .= "Gelegenheid:" . $_POST["gelegenheid"];
$inhoud .= "Plaats:" . $_POST["plaats"];
$inhoud .= "Adres" . $_POST["straat"] . $_POST["nummer"];
$inhoud .= "Datum:" . $_POST["dag"];
$inhoud .= "Set:" . $_POST["set"];
$inhoud .= "Contactgegevens:";
$inhoud .= "Mail Adres:" . $_POST["mail"];
$inhoud .= "Telefoon Nummer:" . $_POST["tel"];
$inhoud .= "Overige Info:" . $overige;
$sturen = mail("qj.somebody@gmail.com","$onderwerp","$inhoud","From: DTM Shows mailing script");
if(sturen){ echo "Bericht verzonden. Er word zo snel mogelijk contact met U opgenomen.";
} else {
echo " <font color='FF0303'>Helaas, het bericht kon niet worden verzonden.<br>";
echo "Waarschijnlijk komt dit door problemen op de server.<br>";
echo "Probeer het snel nog een keer of probeer het via ons contactformulier.</font>";
} }else{
?>

Hier kunt U een show bestellen.<br>
DTM Shows neemt dan contact met U op over beschikbaarheid e.d.<br>
 <br>
<form action="<?php; echo $_SERVER[PHP_SELF]; ?>" name="bestelform" method="post"><table>
<tr><td>Uw Naam:</td><td><input type="text" name="naam" size="33"></td></tr>
<tr><td>De Gelegenheid:</td><td><input type="text" name="gelegenheid" size="33"></td></tr>
<tr><td>Uw Woonplaats*:</td><td><input type="text" name="plaats" size="33"></td></tr>
<tr><td>Straatnaam en huisnummer:</td><td><input type="text" name="straat" size="26">  <input type="text" name="nummer" size="2"></td></tr>
<tr><td>Datum**</td><td><input type="text" name="dag" size="33"></td></tr>
<tr><td>Set van Uw keuze:</td><td><table>
<tr><td>Basic Set</td><td><input type="radio" name="set" value="basic"></td></tr>
<tr><td>Full Set</td><td><input type="radio" name="set" value="full"></td></tr>
<tr><td>Visual Set</td><td><input type="radio" name="set" value="visual"></td></tr>
<tr><td>Custom Set</td><td><input type="radio" name="set" value="custom"></td></tr>
</table>
<tr><td>Uw E-Mail Adres:</td><td><input type="text" name="mail" size="33"></td></tr>
<tr><td>Uw Telefoonnummer:</td><td><input type="text" name="tel" size="33"></td></tr>
<tr><td>Overige Informatie:</td><td> </td></tr>
<tr><td> </td><td><textarea name="overig" rows="10" cols="40">Dit deel is niet verplicht! </textarea></td></tr>
</table> <br>
<center><input type="submit" name="bestel3" value="Bestellen"> <input type="reset" name="clear" value="Reset"></center>
</form><br>
 <br>
* Wij verzorgen alleen shows in Noord Brabant.<br>
**De datum waarop U ons wil inhuren, niet waarop U dit invult.

<?php
}
?>



Just hope [PHP ] is a code here
[edit]
Nope, won't work.
Changed it to [html ].
[/edit]


My guess is to put something at the end off
Code:
 
$inhoud = "Naam:" . $_POST["naam"];

(And the ones below it, you get the idea)

But what??
\n and <BR> both won't do it.

\n gives:
Parse error: parse error, unexpected T_STRING in /data/members/paid/s/c/scifispace.net/htdocs/trekgate/testing dir/roy/sale.php on line 10

<BR> just ads <BR> to the line.
(So not creating a new line, but just <BR>)


I searched, but can't find it :(

Thnx to anybody bothering to awnser.
Offline Profile Quote Post Goto Top
 
JCink
Member
[ *  *  *  *  * ]
I have no idea what's going on there. Rather than put each thing in a varible like that, I do like this:

Code:
 

if ($_POST['email']) {
$members = $_POST['email'];
$mailsub = "Your Account At JShoutBox";
$mailbody = "Hello. Thank you for signing up with our service.\n\Your Information is as follows:\n\--------------------------\n\Box ID: $idnumber\n\Password: $postpassword\n\Your Shoutbox CP is located here: http://jcinkcom.ho8.com/ShoutBoxService/acp/?shoutboxid=$idnumber\n\n\n\To use your shoutbox, visit the HTMLCODE section of your shoutbox Control Panel. Inside it are codes. From there you can paste these codes and your shoutbox will be on your site!\n\Thanks for choosing Jshoutbox.";
$headers = "From: $hd\n";
mail($members,$mailsub,$mailbody,$headers);
echo "<font color=silver>Thank you for sigining up! Please check your email address ( $members ) for further instructions on using your new account with us.</font>";
} else {
echo


\n works fine within there.

I just have some slashes in places I shouldn't. But I use this code and I have no problem.

I know this isn't solving the problem, but you could switch over to something like this.
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
Changing
Code:
 
$inhoud = "Naam:" . $_POST["naam"];

to
Code:
 
$inhoud = 'Naam: $_POST["naam"]\n';

did it.

Thnx.

EDIT:

Still not :(:(

*Qj starts to think a bit

Code:
 
$inhoud = "Naam:" .  $_POST["naam"] . "\n";


That does it :):)

yay!
Offline Profile Quote Post Goto Top
 
Jeremy
Member Avatar
Member
[ *  *  *  *  *  * ]
Just keep in mind that strings surrounded in single quotes aren't parsed for special items, like variables or any of the backslash items ( \n, \t, \s, etc. ). If you want to use a literal new line, \n has to be within double quotes. :)
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
Create your own social network with a free forum.
« Previous Topic · Technology Chat · Next Topic »
Add Reply