I got this php code from this question found at this URL PHP write file from input to txt, I was able to edit the code to make it work for what I am trying to do, however I am having some difficulty in getting this to work.
This is the php code that I have
<?php
$txt = "data.txt";
if (isset($_POST['1']) && isset($_POST['2']) && isset($_POST['3']) && isset($_POST['2']) && isset($_POST['4']) && isset($_POST['5']) && isset($_POST['6']) && isset($_POST['7']) && isset($_POST['9']) && isset($_POST['8']) && isset($_POST['11']) && isset($_POST['c1']))
{ // check if both fields are set
$fh = fopen($txt, 'a');
$txt=$_POST['1'].''.$_POST['2'].''.$_POST['3'].''.$_POST['2'].''.$_POST['4'].''.$_POST['5'].''.$_POST['6'].''.$_POST['7'].''.$_POST['9'].''.$_POST['8'].'
'.$_POST['11'].'
'.$_POST['c1'];
fwrite($fh,$txt); // Write information to the file
fclose($fh); // Close the file
}
?>
The part that I need help on is this, when I make any edits to this line of code $txt = "data.txt";
, the whole page is goes blank.
I need to replace the word “data” with this line of code <?php echo htmlspecialchars($_SESSION["username"]); ?>
unfortunately when I do that, the page goes blank, then I tried to replace that with this line of code $_POST["name01"] .
as on the previous page a text box would have this line of code <?php echo htmlspecialchars($_SESSION["username"]); ?>
, so when the form is submitted on this page I would see the username i.e. Biden, Bob, Sam, etc however that also yields the same results in a blank page.