query($sql); // redirect to new page header('Location: /blog/' . $conn->insert_id); exit; ?>
{$name}This code generates a new product page dynamically using the input data from a form and writes the page content to a file. It uses the built-in file functions in PHP to write the file. In conclusion, the package libraries used in these examples are MySQLi and the built-in file functions.{$description}
Price: \${$price}
EOD; // write page content to file $page_filename = 'products/' . strtolower(str_replace(' ', '-', $name)) . '.php'; $file = fopen($page_filename, 'w'); fwrite($file, $page_content); fclose($file); // redirect to new page header('Location: /' . $page_filename); exit; ?>