Welcome Guest, Not a member yet? Register   Sign In
post method doesn´t work
#1

[eluser]topostangry[/eluser]
Hello i used the codeigniter 2.1.4 version

i have done a <form> with method post but it doesn´t work, i have already been trying it 5 days please help me.with get method works well.

I have test it with the raw code of codeigniter and a simple form with only one input but is the same case,
it doesn´t work.

i have remove the index.php with the .htacces

controllers:

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

class Welcome extends CI_Controller {


public function index()
{
  $this->load->helper('form');
  $this->load->view('welcome_message');
}
}


singUp:

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

class SingUp extends CI_Controller {


public function index()
{
  $this->load->view('welcome_message');
}

public function validate(){

  var_dump($_POST);
  var_dump($_GET);
  if($this->input->post('user')){
   echo "ok";
  }else{
   echo "estoy jodidisimo";
  }
}
  
}


views:

welcome_message: with the form
Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Welcome to CodeIgniter&lt;/title&gt;


<div id="container">
&lt;form action="sinUp/validate" method="post"&gt;
  &lt;input type="text" name="user"&gt;
  &lt;input type="submit" name="sumbit"&gt;
&lt;/form&gt;
</div>

&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]noideawhattotypehere[/eluser]
fix your class name:
Code:
class Signup extends CI_Controller {
...
}

then in your view
Code:
&lt;?php echo form_open('signup/validate');?&gt;
instead of
Code:
&lt;form acti method="post"&gt;
#3

[eluser]topostangry[/eluser]
[quote author="noideawhattotypehere" date="1383154763"]fix your class name:
Code:
class Signup extends CI_Controller {
...
}

then in your view
Code:
&lt;?php echo form_open('signup/validate');?&gt;
instead of
Code:
&lt;form acti method="post"&gt;
[/quote]

no it doesnt work, and i have load the form helper
i am using wampserver
thank you for your attention
#4

[eluser]Tpojka[/eluser]
That code will require url helper loaded.
Also load constructor method:
Code:
public function __construct()
       {
            parent::__construct();
            // Your own constructor code if any - helpers and libraries...
       }
#5

[eluser]topostangry[/eluser]
[quote author="Tpojka" date="1383157413"]That code will require url helper loaded.
Also load constructor method:
Code:
public function __construct()
       {
            parent::__construct();
            // Your own constructor code if any - helpers and libraries...
       }
[/quote]


i have added contructors in controllers and i have loaded url and form helpers in autoload
it doesnt work
#6

[eluser]topostangry[/eluser]
i have tried with xammp and it works, my xammp php version is php 5.2, i think that the problem is the wampserver because in newest versions and last versions it doesnt work
#7

[eluser]Tpojka[/eluser]
Try with school example of form validation.
Don't forget to load form_validation library.
Good luck and set us know if worked.
#8

[eluser]topostangry[/eluser]
Hello peple, i have a conclusion about this

the proble is that codeigniter 2.1.4 has compatibility problems with php5.3,5.4

xamm(php 5.4, 5.3) doesnt work
wamp(php 5.4, 5.3) doesnt work

xammp(php5.2) it works
wamp(php5.2) it works

post method withouth codeigniter works in all versions

thank you for your atention
#9

[eluser]InsiteFX[/eluser]
I' am running PHP 5.3 with Xampp and post works fine, so your problem is in your coding.

Also you should always give your form inputs an id="user"

This uses Twitter Bootstrap 3.0 but should give you an idea.

Code:
<div class="col-lg-3"></div>
<div class="col-lg-6">
<div class="panel panel-default">
    <div class="panel-heading"><h3 class="panel-title">User Login.</h3></div>

  &lt;form method="POST" class="form-horizontal" role="form"&gt;
   <div class="panel-body">
    <fieldset>
     <div class="form-group">
      <label for="user_name" class="col-lg-5 control-label">User name:</label>
      <div class="col-lg-7">
       &lt;input type="text" class="form-control" id="user_name" name="user_name" placeholder="User name" value="&lt;?php echo set_value('user_name'); ?&gt;"&gt;&lt;?php echo form_error('user_name'); ?&gt;
      </div>
     </div>

     <div class="form-group">
      <label for="user_password" class="col-lg-5 control-label">Password:</label>
      <div class="col-lg-7">
       &lt;input type="password" class="form-control" id="user_password" name="user_password" placeholder="Password" value="&lt;?php echo set_value('user_password'); ?&gt;"&gt;&lt;?php echo form_error('user_password'); ?&gt;
      </div>
     </div>

     <div class="form-group">
      <div class="col-lg-offset-5 col-lg-7">
       <div class="checkbox">
        <label>
         &lt;input type="checkbox" id="user_remember_me" name="user_remember_me" value="1" &lt;?php echo set_checkbox('user_remember_me', '1', FALSE); ?&gt;&gt; Remember me.
        </label>
       </div>
      </div>
     </div>

     <hr />

     <div class="form-group">
      <div class="col-lg-offset-5 col-lg-7">
       <button type="submit" class="btn btn-primary" name="login" value="Login">Login</button>
      </div>
     </div>
    </fieldset>
   </div>
  &lt;/form&gt;

</div>
</div>

<div class="col-lg-3"></div>




Theme © iAndrew 2016 - Forum software by © MyBB