E-mail activation not working with php mail

Is it possible to do something like the following? I would like to add more than one variable and even better if I could make it more reader friendly such as including first name: last name: username: etc before the variables?

fwrite($file, $first, $last, $uid);

I tried the above but it doesn’t work. I guess I need to declare separate variables for it such as
$first_name = 'First Name: '.$first;

Is that the correct syntax?

You could write the file with this syntax:
fwrite($file, $first . "<br />" . $last . "<br />" . $uid);
and define $first as "First Name: " . $_POST["fname"], $last as "Last Name: " . $_POST["lname"] and $uid as "Username: " . $_POST["uid"], considering that the names of the input fields are fname, lname and uid.

So whenever you concatenate, the last variable does not need to end with a dot? Also, when would I know when to use a double quotation as opposed to a single quotation? For example, in my body section, I have this but if I were to change it to a single quotation, then it doesn’t work? or maybe my syntax would be different then, for the variable $first and $last?

$mail->Body = “

Dear $first $last,

Thank you for registering your Primer Level Membership Plan with PianoCourse101! h1>”;

Whenever you concatenate, the last variable must not be concatenated with nothing on PHP. Always use the coding mode while you select the lines to do this example, otherwise the forum will not know them and the result is a bit messy! Here is the screenshot of where you can find it:
Screenshot%20at%20giu%2015%2017-08-36
However, you can define the variables $fname and $lname as the $_POST["fname"] and the $_POST["lname"] and use them, like on this syntax:
$mail->Body = "<h1>Dear ".$fname." ".$lname.", <br /> Thank you for registering your Primer Level Membership Plan with PianoCourse101!</h1>";

What is the coding mode? For some reason, the information saved in my text file does not have line breaks and I have the following code:

fwrite($file, $first_invoice.“
”.$last_invoice.“
”.$uid_invoice.“
”.$email_invoice);

First Name: Me
Last Name: L
Username: piano0011<

But the mail configuration has the line $mail->isHTML(true) and the file will be a HTML file! So fwrite($file, $first_invoice."<br />".$last_invoice."<br />".$uid_invoice."<br />".$email_invoice);

However, the coding mode is a mode that evidences the text with a monospace font.

I am confused here but then in my file, should it have a line break because
is a html format but all my information are displayed on the same line?

Yes, it should have a line break because then the designers think “Eh, but you didn’t add line breaks, because the information is showed on the same line!” and the line breaks create a new line with the other part of the information.

I am still confused because the
is not working…It should be showing the br tag but not in my previous sentence

Is there a format to use here when including codes?

Use grave accents at the start and at the end of every word to make it monospaced. Example: test.

How do I do that here? Are you talking about using the preformatted text? I still can’t get the line break to work… the br tag is not working the`
tag is not working.

Can I also do something like this to check if the file exists?

if (!$newfile) {

$newfile = "invoice/PrimerLevelAccount_".$uid."_".$date;

$file = fopen($newfile, "w");

fwrite($file, $first_invoice."&lt;br /&gt;&lt;br /&gt;".$last_invoice."&lt;br /&gt;".$uid_invoice."&lt;br /&gt;".$email_invoice);

fclose($file);

} else {

$file = fopen($newfile, "a");

fwrite($file, $first_invoice."&lt;br /&gt;&lt;br /&gt;".$last_invoice."&lt;br /&gt;".$uid_invoice."&lt;br /&gt;".$email_invoice);

fclose($file);

}

I’m now actually seeing the monospace text that “the <br /> tag is not working”. Always use monospaced text while you format the file.
You can actually do something to check if the file exists, but combined with my sketches, like this:
if(!$newfile){
$newfile = "invoice/PrimerLevelAccount_".$uid."_".$date.".html";
$file = fopen($newfile, "w");
fwrite($file, $first_invoice."<br /><br />".$last_invoice."<br /><br />".$uid_invoice."<br /><br />".$email_invoice);
fclose($file);
}else{
$file = fopen($newfile, "a");
fwrite($file, $first_invoice."<br /><br />".$last_invoice."<br /><br />".$uid_invoice."<br /><br />".$email_invoice);
fclose($file);
}

You included the .html again… :grinning: but how come I am still not seeing any line break?

Last Name:First Name: Mervin<br /><br /> Lee<br /> It is showing this in my invoice folder instead of literally showing a line break…

I like the First Name to be on a new line

For me it works with this code:

<?php

$file = fopen("test.html", "w");

fwrite($file, "test<br />test<br />test<br />test");

fclose($file);

?>

and I can see the test file perfectly with line breaks in my browser.

When I tried to download the attachment and view it in notepad editor, it doesn’t show the line break

But what happens when you visit the HTML code in the browser (not the Monsta FTP you’re on)?

I actually didn’t output this in the browser… I have a different message in the browser but these are the credentials for the customer to see in the file only…I actually would eventually say something like… Dear Valued Customer, <br /></br />Here are your credentials, please keep it somewhere safe.<br /></br />You can change them anytime in the update profile section<br /><br />From,<br /><br />PianoCourse101.

Can I do something like this?

fwrite($file, "Dear Valued Customer".$first_invoice."&lt;br /&gt;&lt;br /&gt;".$last_invoice."&lt;br /&gt;".$uid_invoice."&lt;br /&gt;".$email_invoice);

or must I add Dear Valued Customer as a string?

I tried it but it is still displayinig the
as a text output instead of html...Maybe there is something wrong with the quotation mark around it? The strange thing is that it does work with \n. What is the difference between \n and <br /> tag?

I guess I read somewhere that the <br /> tag will only work if using a browser and anything else, I need to use the \n correct?

Also, I am a bit confused here… should I place the $newfile outside the if statement or after the if statement? If the file does not exist, then create it, so it should be after the if statement? or must I create the file first so that the code knows how to check for it?

if(!file_exists($newfile)) {

$newfile = "invoice/PrimerLevelAccount_".$uid."_".$date;

$file = fopen($newfile, "w");

fwrite($file, "Dear Valued Customer ,\n".$first_invoice."\n".$last_invoice."\n".$uid_invoice."\n".$email_invoice);

fclose($file);

} else {

$file = fopen($newfile, "a");

fwrite($file, $first_invoice."&lt;br /&gt;&lt;br /&gt;".$last_invoice."&lt;br /&gt;".$uid_invoice."&lt;br /&gt;".$email_invoice);

fclose($file);

}

Should I stick with \n\n instead of break tag?

I guess I will stick with the \n but just like someone to confirm if I should be able to use the break tag? I guess this only works in the browser?