Remi Hirtz
Remi Hirtz

Reputation: 144

codeigniter form, no action when submited

I'm trying to make a codeigniter form, but when I press the button nothing happen. I've already checked everything a thousand time but nothing happen.

Here is the form code:

    $this->load->helper('form');
$this->load->helper('captcha');

$attributs = array('class' => 'col-md-12 col-xs-12', 'id' => 'inscription');
echo form_open('utilisateur/ajouter', $attributs);
echo "Nom <br>".form_input('nom','test')."<br>";
echo "Prénom <br>".form_input('prenom','test')."<br>";
echo "Age <br>".form_input('age','test')."<br>";
echo "Pseudo <br>".form_input('pseudo','test')."<br>";
echo "Email <br>".form_input('email','test')."<br>";
echo "Mot de passe <br>".form_password('mdp','test')."<br>";
echo "Confirmation <br>".form_password('mdpConf','test')."<br>";
$bouton = array(
    'name' => 'button',
    'class' => 'button',
    'content' => 'Valider !'
);
echo "<br>".form_button($bouton);
echo form_close();

And the controller called code:

    class Utilisateur extends CI_Controller {
    protected $Pseudo;
    protected $Email;
    protected $Nom;
    protected $Prenom;
    protected $Age;
    protected $DateInscription;

    public function __construct()
    {
        parent::__construct();
        $this->Pseudo=$Pseudo;
        $this->Email=$Email;
        $this->Nom=$Nom;
        $this->Prenom=$Prenom;
        $this->Age=$Age;
        $this->DateInscription=$DateInscription;
    }
    public function ajouter()
    {
        redirect('pages/view/accueil/', 'location');
    }
}

Upvotes: 0

Views: 492

Answers (2)

Niranjan N Raju
Niranjan N Raju

Reputation: 11987

use form_submit(),

echo form_submit('mysubmit', 'Submit Post!');

Would produce:

<input type="submit" name="mysubmit" value="Submit Post!" />

In your case,

form_submit($bouton);

would produce

<input type="submit" content="Valider !" class="button" value="" name="button">

Is Anything missing??

Answer is yes.

What?

Value to submit button.

$bouton = array(
    'name' => 'button',
    'class' => 'button',
    'content' => 'Valider !',//this will work for button, not submit button.
    'value' => 'Valider !'     

);

For more reference, see this

Upvotes: 0

craig_h
craig_h

Reputation: 32714

I haven't used codeignitor for quite some time, but surely if you want to submit the form you should be using form_submit($bouton); rather than form_button($bouton);

Upvotes: 1

Related Questions