myWhen点击提交按钮后,页面重新加载显示URL中的输入值,就好像它正在使用GET一样。没有其他事情发生。甚至验证功能都没有运行。
<?php echo form_open("auth/login"); ?>
<label for="inputClientID" class="sr-only">Client ID</label>
<input type="clientID" name="clientID" id="inputClientID" class="form-control" placeholder="Client ID" required autofocus>
<label for="inputloginID" class="sr-only">Login ID</label>
<input type="loginID" name="loginID" id="inputloginID" class="form-control" placeholder="Login ID" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
<?php echo form_close(); ?>
我正在使用PHP CodeIgniter。我试图使用纯HTML而不是CI form_open()方法构建表单 - 仍然显示相同的问题。
这是代码在浏览器中的加载方式,显然没关系:
<form action="https://mywebsite.com/auth/login" method="post" accept-charset="utf-8">
<label for="inputClientID" class="sr-only">Client ID</label>
<input type="clientID" name="clientID" id="inputClientID" class="form-control" placeholder="Client ID" required autofocus>
<label for="inputloginID" class="sr-only">Login ID</label>
<input type="loginID" name="loginID" id="inputloginID" class="form-control" placeholder="Login ID" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
</form>
然后,这是在点击提交按钮并重新加载页面后网址的样子:
https://mywebsite.com/?clientID=1&loginID=samplelogin
在我的合作伙伴使用BootStrap添加了一些格式之后,它开始发生了(也许这只是巧合)。
提前致谢
编辑:
&LT;&LT; “验证/登录”&gt;&gt;
public function login() {
$this->form_validation->set_rules('clientID', 'Client ID', 'required|numeric');
$this->form_validation->set_rules('loginID', 'Login ID', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('defaultheader', array('title' =>
"MyWebsite | Login"));
$this->load->view("loginpage");
} else {
echo "it works";
$clientID = $this->input->post("clientID");
$loginID = $this->input->post("loginID");
$password = $this->input->post("password");
$user_check = $this->auth_model->check_credentials($clientID, $loginID, $password);
switch ($user_check) {
case 1:
$this->check_first_access($loginID,$clientID);
break;
case 0:
$message = "Wrong Client ID / Login ID / Password combination.";
$this->load->view('defaultheader');
$this->load->view('loginpage', array('message' => $message));
break;
case -1:
$message = "User deactivated";
$this->load->view('defaultheader');
$this->load->view('loginpage', array('message' => $message));
break;
}
}
}
&LT;&LT;路线文件&gt;&gt;
$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
&LT;&LT; .htaccess文件&gt;&gt;
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|mywebsite|phpmyadmin|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
答案 0 :(得分:2)
使用get方法
尝试使用以下代码$data = array(
'method' => 'get'
);
echo form_open('auth/login', $data);
答案 1 :(得分:0)
您需要添加结尾斜杠:
<?php echo form_open("auth/login/"); ?>
答案 2 :(得分:0)
我不知道这是不是 - 但我会尝试更改表单字段以键入=&#39; text&#39;
所以喜欢这个
<input type="clientID" name="clientID" id="inputClientID" class="form-control" placeholder="Client ID" required autofocus>
更改为
<input type="text" name="clientID" id="inputClientID" class="form-control" placeholder="Client ID" required autofocus>