首页 > Web开发 > 详细

PHP的两种表单数据提交方式

时间:2016-12-11 23:23:56      阅读:296      评论:0      收藏:0      [点我收藏+]

1 通过隐藏表单提交

    //通过隐藏表单提交
    if ($_POST[‘action‘] == ‘register‘){
        echo ‘你提交了数据‘;
        exit();
    }
?>

<!DOCTYPE html>
<head>
</head>
<body>
    <div id=‘register‘>
        <form method="post" name="register" action="register.php">
            <input type="hidden" name="action" value="register" />
            <ul>
                <h2>请认真填写一下内容</h2>
                <li>用&#8194户&#8194名:<input type=‘text‘ name=‘username‘ class=‘text‘ />(*必填,至少两位)</li>
                <li>密&#12288&#12288码:<input type=‘password‘ name=‘password‘ class=‘text‘ />(*必填,至少两位)</li>
                <li><input type=‘submit‘ value=‘提交‘  /></li>
            </ul>
        </form>
    </div>
</body>

2 通过?后的后缀提交数据

<?php 
   if ($_GET[‘action‘] == ‘register‘){
       echo ‘你提交了数据‘;
       exit();
   }
?>

<!DOCTYPE html>
<head>
</head>
<body>
    <div id=‘register‘>
        <form method="post" name="register" action="register.php?action=register">
            <ul>
                <h2>请认真填写一下内容</h2>
                <li>用&#8194户&#8194名:<input type=‘text‘ name=‘username‘ class=‘text‘ />(*必填,至少两位)</li>
                <li>密&#12288&#12288码:<input type=‘password‘ name=‘password‘ class=‘text‘ />(*必填,至少两位)</li>
                <li><input type=‘submit‘ value=‘提交‘  /></li>
            </ul>
        </form>
    </div>
</body>

 

PHP的两种表单数据提交方式

原文:http://www.cnblogs.com/by-dxm/p/6160892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!