PHP与表单的简单应用

HTML代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <title></title>
</head>
<body>
<form action="actionPhp.php" method="POST"  enctype="multipart/form-data">
    <label for="username">姓名</label>
    <input type="text" name="username" id="username"><br/>
    <label for="sex">性别</label>
    <input type="radio" name="sex" id="sex" value="man">man
    <input type="radio" name="sex" id="sex" value="woman">woman<br/>
    <label for="pwd">密码</label>
    <input type="password" name="pwd" id="pwd"><br/>
    <label for="edu">学历</label>
    <select name="edu" id="edu">
        <option value="collage">collage</option>
        <option value="highschool">high school</option>
        <option value="graduated">graduated</option>
    </select><br/>
    <label for="hobby">爱好</label>
    <input type="checkbox" name="hobby[]" value="book">book
    <input type="checkbox" name="hobby[]" value="paint">paint
    <input type="checkbox" name="hobby[]" value="sing">sing<br/>
    <label for="pic">照片</label>
    <input type="file" name="pic" id="pic"><br/>
    <label for="info">个人简介</label>
    <textarea name="info" id="info"></textarea>
    <input type="submit" name="submit">
</form>
</body>
</html>

PHP代码

<?php
    if($_POST['submit']!=""){
        echo "username is $_POST[username]<br/>";
        echo "sex is $_POST[sex]<br/>";
        echo "password is $_POST[pwd]<br/>";
        echo "school is $_POST[edu]<br/>";
        echo "hobbys is";
        for($i=0;$i<count($_POST['hobby']);$i++)
            echo $_POST['hobby'][$i];
        echo '<br/>';
        $path='./upfile/'.$_FILES['pic']['name'];
        move_uploaded_file($_FILES['pic']['tmp_name'], $path);
        echo "information is $_POST[info]";
    }
?>

HTML
PHP

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值