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;
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:
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>";
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.
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.
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?
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);
}
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.
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?