The PHP code I have currently sends the data that is posted in my form to a file called newData.html. I would like it to send the data to a file that is named the same as the product name in the data.
For example, I have a product called the NS-4000. I enter the product's name in the product name blank on my form and submit the form. I want for a file named, NS-4000.html to be created with the other data pieces I have going there. In this case, I would have the name of the project lead, a description of the product and the names of the team members. This is the PHP I have so far:
<?php
$Name = $_POST['Name'];
$PLname= $_POST['PLname'];
$Team_members= $_POST['Team_members'];
$Description= $_POST['Description'];
$html = <<<HEREDOC
Product Name: $Name <br>
Project Lead: $PLname <br>
Team Members: $Team_members <br> <br>
Description: $Description
HEREDOC;
file_put_contents('newPage.html', $html);
header('location: newPage.html');
exit;
How would I go about having my PHP code create a file with the same name as the product name in the form?
$Nameto construct the filename of the file which will contain your data.strtolowerfor your naming convention, should the name start with a capital letter; e.g. John.$fp = fopen(strtolower($Name) . ".html", 'w');or$fp = fopen(strtolower($Name) . 'w');thought you might need it, just in case.