How to create an unregistered Codeigniter registration form?

Here is what I am trying to do.

I want to have a home page with my registration form, which does not refresh the page every time the verification step is not completed.

I want my registration form to have 2 steps.

The form fields of the first step form and the date of the drop-down list. When all this succeeds, it will be sent to captcha without refreshing the page or even popup using captcha. When the pass-through is successful, the user will be registered.

Currently, when validating the validation, my controller loads the submit_success.php view ..

What is the best way to achieve what I'm trying to do?

Ajax? Javascript

Are there any coding tutorials you can tell me?

Or could you give me an example?

+3
source share
2 answers

You can make ajax requests back to CI to check with $. ajax or $ .post, so you will need to create validation rules in CI.

Here is an example I found for you to get started: jquery post codeigniter validation

And here is an example of CodeIgniter Captcha with ajax: http://www.99points.info/2010/03/verify-captcha-with-ajax-using-codeignite/

+2
source
//html function 
<div id="report"></div>
<form>
username : <input type="text" id="username" />
password : <input type="password" id="password" />
<input type="button" id="submit" onclick="validate();" value="sign in" />
</form>

//javascript function
function validate()
{



                var username = $("#username").val();//get value for username via d username id
                var password = $("#password").val();//get the value for password via d password id






                var url_link = "http://localhost/site_root/controller/blank";
                var reload_url = "http://localhost/site_root/controller/validation_function";
                var form_data = {
                username: username,
                password: password,
                ajax : '1'
                };
                $.ajax({
                url: url_link,
                type: 'POST',
                async : false,
                data: form_data,
                success: function() {

                 $("#report").load(reload_url);


                }
                });
                return false;
}


//controller

<?php if(!defined("BASEPATH")) exit("no direct access allowed");

class Controller extends CI_controller
{

        function  __construct()
        {
        parent::_construct();
        }


        function blank()
        {

        }



        function validate_function()
        {
        $username = $this->input->post->("username");
        $password = $this->input->post->("password");

        /*
        perform db validation if passed redirect user to the ideal url (logged in user page)
        */
        else
        /*
        $this->load-view("wrong_credentials");
        */


        }


}
?>

//wrong_credentials.php view

<?php
echo "wrong user name and password combination . try again";
?>
0
source

Source: https://habr.com/ru/post/1765541/


All Articles