php--05

<?php
header("content-type:text/html;charset=utf-8");

// $a = 1;
// echo $GLOBALS;

// echo $_SERVER;
// echo $_ENV;


// var_dump($_REQUEST);

var_dump($_POST);

// var_dump($_GET);

//文件上传
/**
 * form标签需添加 enctype="multipart/form-data"属性
 */
if($_FILES){
    var_dump($_FILES);
    $expt = explode('.',$_FILES['imgs']['name']);
    $e = end($expt);
    //文件限制
    $file = $_FILES['imgs']['type'];
    $file_size = $_FILES['imgs']['size'];
    if($file == 'image/page' or $file == 'image/jpg' or $file == 'image/gif' or $file == 'image/jpeg' and $file_size < 1024*1024){
        if($_FILES['error']){
            echo $_FILES['error'];
        }else{
            //存储文件
            move_uploaded_file($_FILES['imgs']['tmp_name'],'./upload/a'.time().'.'.$e);
        }
    }else{
        echo '文件格式错误';
    }   
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="" method="POST" enctype="multipart/form-data" onsubmit="return sub();">
        账号:<input type="text" name="uname">
        <br>
        密码:<input type="password" name="pwd" id="mm">
        <br>
        确认密码:<input type="password" name="qrpwd" id="qrmm">
        单选框:
        <input type="radio" name="sex" value="男">男
        <br>
        <input type="radio" name="sex" value="女">女
        <br>
        复选框:
        <input type="checkbox" name="fuxuan[]" value="1">1
        <br>
        <input type="checkbox" name="fuxuan[]" value="2">2
        <br>
        <input type="checkbox" name="fuxuan[]" value="3">3
        <br>
        下拉:
        <select name="diqu" >
            <option value="山东">山东</option>
            <option value="北京">北京</option>
            <option value="上海">上海</option>
            <option value="广州">广州</option>
        </select>
        <br>
        文本域:
        <textarea name="message" cols="30" rows="10"></textarea>
        <br>
        <input type="file" name="imgs" id="">
        <br>
        <input type="submit" value="登录">
    </form>
</body>
<script>
    function sub(){
        var mm = document.getElementById('mm').value;
        console.log(mm);

        var qrmm = document.getElementById('qrmm').value;
        console.log(qrmm);
        if(mm == qrmm){
            return true;
        }else{
            alert('密码输入错误');
            return false;
        }
    }
</script>
</html>
posted @ 2021-01-09 11:22  孙旋  阅读(37)  评论(0编辑  收藏  举报