首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么不使用操作,我的表单仍然将数据存储到数据库中

为什么不使用操作,我的表单仍然将数据存储到数据库中
EN

Stack Overflow用户
提问于 2014-06-09 13:52:37
回答 1查看 83关注 0票数 0

我正在考虑在表单中插入catcha过程,所以我在考虑一些逻辑,所以我从google下载了一个登录,但是我不明白。为什么我的表单仍然使用action=' '将数据存储到数据库中,而它是action="register.php"附带的,但是正如我告诉您的,我正在做一些逻辑学方面的工作,所以您能告诉我这里有什么问题吗?

这是我的完整代码:

代码语言:javascript
运行
复制
<?php
// show potential errors / feedback (from registration object)
if (isset($registration)) {
    if ($registration->errors) {
        foreach ($registration->errors as $error) {
            echo '<div class="alert-box error"><span>Error: </span>'.$error.'</div>';
        }
    }
    if ($registration->messages) {
        foreach ($registration->messages as $message) {
            echo '<div class="alert-box success"><span>Success: </span>'.$message.'</div>';
        }
    }
}
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Registration with Linkvessel and collaborate with college's friends</title>
        <link rel='stylesheet' type='text/css' href="./CSS_files/registration_style.css" />
        <link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap-responsive.css" />
        <link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap-responsive.min.css"/>
        <link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.css" />
        <link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="./bootstrap/js/bootstrap.js" />
        <link rel="stylesheet" type="text/css" href="./bootstrap/js/bootstrap.min.js" />
         <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
        <script>
            $(function(){
                $("#datepicker").datepicker();
            });            
        </script>
        <style>
            .alert-box {
        color:#555;
        border-radius: 0px;
        font-family:Tahoma,Geneva,Arial,sans-serif; font-size:11px; font-size: 18px;
        padding:  30px 36px;
        margin:10px;
            }
            .alert-box span {
        font-weight:bold;
        text-transform:uppercase;
            }
            .error {
        border:2px solid #0c0b0b;
                background-color: #ff7e48;
            }

            .success{
            border:2px solid #0c0b0b;
            background-color: #a3ea42;
            }
        </style>
    </head>
    <body>
        <div id="header">
            <img id="logo_size" src="./images/logo.png" onmousedown="return false">
        </div><br><br><br>

        <form id="form_box" method="post" action='' name="registerform">
                <div id="title">
                    <h2>REGISTRATION FORM</h2>
                </div>

                <div class="controls pos_selectbox">
                    <select id="basic" name="user_college" class="input-medium">
                        <option>Select College</option>
                        <option>MAIIT kota</option>
                    </select>&nbsp; &nbsp;

                    <select id="basic" name="user_branch" class="input-medium">
                        <option>Select Branch</option>
                        <option>Computer science</option>
                        <option>Civil</option>
                        <option>Mechanical</option>
                        <option>Electrical</option>
                        <option>Bioinformatic</option>
                    </select>&nbsp; &nbsp;

                    <select id="basic" name="user_year" class="input-medium">
                        <option>Select year</option>
                        <option>1st year</option>
                        <option>2nd year</option>
                        <option>3rd year</option>
                        <option>4th year</option>
                        <option>Year completed</option>
                    </select>&nbsp; &nbsp;
                </div><br>

                <input id="input_pos" type="email" name="user_email" required="" placeholder="Email address" /><br><br>

                <input id="input_pos" type="password" name="user_password_new" required="" placeholder="Password" /><br><br>

                <input id="input_pos" type="password" name="user_password_repeat" required="" placeholder="Confirm password" /><br><br>

                <input id="name_pos" type="text" name="user_firstname" required="" placeholder="First name" />&nbsp;

                <input id="name_pos2" type="text" name="user_lastname" required="" placeholder="Last name" /><br><br>

                <input id="datepicker" type="text" name="user_dob" required="" placeholder="Date of birth" /><br><br>

                <input id="name_pos" type="text" name="user_state" required="" placeholder="State" />&nbsp;

                <input id="name_pos2" type="text" name="user_city" required="" placeholder="city" />&nbsp;<br><br>

                <input type="submit" name="register" id="pos_submit" class="btn btn-primary btn-large" value="Create account.."/>
            </form>
</html>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-09 13:54:02

窗体操作属性的空值默认为当前URL。因此,如果该页面的URL为register.php,则action=''与执行action='register.php'相同。

W3C规范表示此行为未指定。但是浏览器已经普遍地实现了上述行为。

最后,使用方法属性指定的协议将编码的数据发送到由action属性指定的处理代理。 此规范没有指定所有可与表单一起使用的有效提交方法或内容类型。但是,在下列情况下,HTML 4用户代理必须支持已建立的约定:

  • 如果方法是"get“且操作是HTTP,则用户代理获取操作的值,并追加一个‘?’然后追加表单数据集,使用“application/x form -urlencoded”内容类型进行编码。然后,用户代理遍历指向此URI的链接。在这种情况下,表单数据仅限于ASCII代码。
  • 如果方法是"post“且操作是HTTP,则用户代理使用action属性值和根据enctype属性指定的内容类型创建的消息进行HTTP "post”事务。

对于操作或方法的任何其他值,未指定行为。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24121749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档