doucitan2544 2015-08-03 12:16
浏览 27

表格方法邮寄不工作

My problem seams to be simple, but I am struggling to get this to work.

Here's my html:

<form class="form" role="form" id="form" method="post" action="<?php echo site_url("register"); ?>" onsubmit="" >
  <div class="col-md-6 col-sm-6 col-xs-12 fm">
    <input type="text" class="form-control" id="email" name="email" 
      value="<?php if(isset($validation_errors['post_data']['email'])) echo $validation_errors['post_data']['email']; ?>" 
      placeholder="Email" >
  </div>
  <div class="text-center">
    <input type="submit" id="btn" name="btn" class="btn" value="Quero ganhar um Cartão">
  </div>
</form>

I made the code a bit simple, so you could read it fast. When I submit the form to the register page, I try to see if it is a post or not like this :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Register extends CI_Controller {

 function Register() {
    parent::__construct();
    $this->load->model('register_model');
 }


 public function index() {
  if($_POST) { echo 'post'; } else { echo 'not a post'; }
 }
}

And the controller keeps printing 'not a post'. It seams like the form only redirect to the URL and do nothing more.

Edit : I did echo $_SERVER['REQUEST_METHOD']; in my controller and it prints " GET ", so, I guess something is wrong with the method ? I Already tried method="POST", method="post" and it keeps printing " GET ". Don't know what else to do.

  • 写回答

2条回答 默认 最新

  • duanqiongchong0354 2015-08-03 12:27
    关注

    add url helper in controller, then only you can access site_url() in your view page

    $this->load->helper('url');
    

    remove unnecessary onsubmit="" in your form tag

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因