1, the front-end displays the create button
Add the following code to the netdisk_html.php page:
<?php <form method="post"> 新建文件夹:<input type="text" name="newfolder"> <input type="submit" value="创建"> </form>
You can write the required in the input box Create the folder name and click Create to submit it through post
2, get
on the index.php page because in the index.php file Require('netdisk_html.php') is introduced, so the default submission is the current page. There is no need to write action="index.php". Of course, no error will be reported if you write it.
Get the post submission Just execute the new folder function on the data. The specific code is as follows:
<?php //获取表单传来的数据 $newfolder=isset($_POST['newfolder'])?trim($_POST['newfolder']):""; //创建文件夹功能 if($newfolder==''){ // echo "创建文件夹失败"; }else{ //不能建已经存在的文件夹--进行判断 $sql="select folder_name from netdisk_folder where folder_pid=$folder_id AND folder_name='$newfolder'"; $allfolder=fetchRow($sql); if($allfolder){ echo "文件名不能重复"; }else{ //正常创建的情况下 $sql="insert into netdisk_folder (folder_name,folder_time,folder_path,folder_pid) values('$newfolder',now(),$folder_id,$folder_id)"; $result=query($sql); if($result){ // echo '添加成功'; }else{ echo '添加失败'; } } }
3, page display: