博客列表 >PHP黏性表单

PHP黏性表单

Pengsir
Pengsir原创
2017年12月29日 13:43:18677浏览

PHP代码

<?php
    if($_SERVER['REQUEST_METHOD']=='POST'){
        echo '<script>alert(\'注册成功\')</script>';
    }
?>

HTML代码

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
 content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../dist/css/bootstrap.css">
    <script src="../jquery-3.2.1.min.js"></script>
    <script src="../dist/js/bootstrap.js"></script>
    <title>黏性表单案例</title>
</head>
<body>
<form action="" method="post">
    <div class="container" style="background-color:#c19e66;border-radius: 10px;width: 600px;margin-top: 30px">
        <div class="row">
            <div class="col-md-12">
<!--                <div>-->
 <h3>用户注册</h3>
<!--                </div>-->
 </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="input-group">
                    <span class="input-group-addon" id="basic-addon1">用户名:</span>
                    <input type="text" name="name" value="<?php echo (isset($_POST['name']))? $_POST['name']:''?>">
                </div>
            </div>
        </div>
        <div class="row" style="margin-top: 10px">
            <div class="col-md-12">
                <div class="input-group">
        <span class="input-group-addon" id="basic-addon1">密&nbsp;&nbsp;&nbsp;码:</span>
                    <input type="text" name="password" value="<?php echo (isset($_POST['password']))? $_POST['password']:''?>">
            </div>
            </div>
        </div>
        <div class="row" style="margin-top: 10px">
            <div class="col-md-8">
                <p><span style="margin-left: 10px;margin-top: 10px">
                        <span>性别:</span>
                        <input type="radio" name="sex" value="man" <?php echo (isset($_POST['sex'])&& ($_POST['sex']=='man'))? 'checked' :'' ?>>男
                        <input type="radio" name="sex" value="woman" <?php echo (isset($_POST['sex'])&& ($_POST['sex']=='woman'))? 'checked' :'' ?>>女
                    </span></p>
                <p>
                    <span style="margin-left: 10px;margin-top: 10px;">
                        <span>学历:<select name="xueli" style="margin-left: 5px;padding: 5px ">
                                    <option value="xx" <?php echo (isset($_POST['xueli']) && ($_POST['xueli']=='xx'))? 'selected' :''?>> 小学</option>
        <option value="bz" <?php echo (isset($_POST['xueli']) && ($_POST['xueli']=='bz'))? 'selected' :''?>> 本科</option>
        <option value="bs"<?php echo (isset($_POST['xueli']) && ($_POST['xueli']=='bs'))? 'selected' :''?>> 博士</option>
                            </select>

                        </span>

                    </span>
                </p>
            </div>
        </div>
    <div class='row' style='margin-bottom:20px;margin-left: 10px;' >
    <div class="col-md-12" >
        <div class="btn-group">
            <button class="btn">提交</button>
        </div>
    </div>
</div>
    </div>
</form>
</body>
</html>

效果图:

PHP黏性表单.png

上一条:php短信接口demo下一条:模板制作
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议