简体   繁体   中英

How to generate a php page automatically directing into the root folder using a form?

I want to create a form where different users are able to enter there name, and automatically a php file will be created into the root folder.

For example, www.domain.com/enter your name

When a user enters his/her name, a php file will generate into the root folder. The file will have his/her name on it. And every generate page will contain some codes.

Purpose of this i want to create a CMS where users can build and have their own content.

Its better to use databases, if still you want

then u can try this, In this case if name will not be unique then content will be overridden, so validate and keep track of names;

$username= mysql_real_escape_string($_POST['username']);
$content = "<?php echo '"+$username+"';?>"; // your meassage or whatever text to save in php file.
$fp = fopen($_SERVER['DOCUMENT_ROOT'] ."/".$username.".php","wb");
fwrite($fp,$content);
fclose($fp);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM