Create folder function
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="創(chuàng)建"> </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 //獲取表單傳來的數(shù)據(jù) $newfolder=isset($_POST['newfolder'])?trim($_POST['newfolder']):""; //創(chuàng)建文件夾功能 if($newfolder==''){ // echo "創(chuàng)建文件夾失敗"; }else{ //不能建已經(jīng)存在的文件夾--進(jìn)行判斷 $sql="select folder_name from netdisk_folder where folder_pid=$folder_id AND folder_name='$newfolder'"; $allfolder=fetchRow($sql); if($allfolder){ echo "文件名不能重復(fù)"; }else{ //正常創(chuàng)建的情況下 $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: