【问题标题】:url is change when submit on button在按钮上提交时 url 发生变化
【发布时间】:2020-01-21 10:04:44
【问题描述】:

我正在使用 codeigniter 我的视图文件是

<div class="limiter">
    <div class="container-login100">
        <div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-50" action="<?php base_url('Login')?>" method="post">
            <form class="login100-form validate-form">
                <span class="login100-form-title p-b-33"> Account Login </span>
                <div class="wrap-input100 validate-input" data-validate = "Valid Username is required">
                    <input class="input100" type="text"  id="username" placeholder="Enter Username" name="username"/>
                    <span class="text-danger"><?php echo form_error('username') ?></span>

                </div>
                <div class="wrap-input100 rs1 validate-input" data-validate="Password is required">
                    <input class="input100" type="password"  id="pwd" placeholder="Enter password" name="password"/>
                    <span class="text-danger"><?php echo form_error('password') ?></span>

                </div>
                <div class="container-login100-form-btn m-t-20">
                    <input type="submit" class="btn btn-dark login100-form-btn" name="submit" value="Login"/>
                    <?php echo $this->session->flashdata('error'); ?>
                </div>
                <div class="text-center p-t-45 p-b-4">
                    <span class="txt1"> Forgot  </span>
                    <a href="#" class="txt2 hov1">Username / Password? </a>
                </div>
                <div class="text-center">
                    <span class="txt1">Create an account?</span>
                    <a href="#" class="txt2 hov1"> Sign up</a>
                </div>
            </form>
        </div>
    </div>
</div>

我已经发送了像这个网址这样的帖子请求

http://localhost/openvoips/index.php/Login

但它变成了

http://localhost/openvoips/index.php/Login?username=sanjay&password=12345&submit=Login

如何解决

【问题讨论】:

  • 因为它在form 中的GET 方法的行为。它通过 URL 将数据发送到您的控制器。您在控制器中作为 post metof 访问数据,所以在表单中使用 POST 方法
  • 使用method="POST"
  • &lt;div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-50" action="&lt;?php base_url('Login')?&gt;" method="post"&gt;改成标签,例如&lt;form ...
  • 但我正在发送帖子方法

标签: php codeigniter


【解决方案1】:

您没有发送 post 方法。

尝试更新以下代码库

 <div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-50" action="<?php base_url('Login')?>" method="post">
        <form class="login100-form validate-form">

 <div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-50" >
            <form class="login100-form validate-form" action="<?php base_url('Login')?>" method="post">

【讨论】:

    猜你喜欢
    • 2019-05-08
    • 2013-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-22
    • 1970-01-01
    • 2015-12-22
    相关资源
    最近更新 更多