PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Now I would like to do a text box so the user enters a name and the script will make the folder's name that the user wanted. Any one knows how i can do it? Thanks
// The HTML file that the user enters the dir name into.
<html>
<head>
<title>Folder Creation Form</title>
</head>
<body>
<form action=""http://127.0.0.1/create_dir.php" method="post"> //Give the file path here
<input type="text" name="dir_name">
<input type="submit" value="Submit" name="Submit">
</form>
</body>
</html>
//The backend PHP that will process it!
<?php
if (isset($_POST['dir_name'])) {
$dir_name = $_POST['dir_name'];
if (preg_match("^[^\\\/\?\*\"\>\<\:\|]*$", $dir_name)) {
mkdir($dir_name, 0700);
echo "Folder ".$dir_name." created successfully!";
}
else {
echo "Invalid folder name, please try again!";
}
}
else {
echo "You must provide a folder name to continue.";
}
?>