Commit 6a7343ad by tetiana yaremko

email availability using ajax in registration form

parent 52da0056
...@@ -23,8 +23,8 @@ defined('BASEPATH') OR exit('No direct script access allowed'); ...@@ -23,8 +23,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| a PHP script and you can easily do that on your own. | a PHP script and you can easily do that on your own.
| |
*/ */
$config['base_url'] = 'https://wbt-2-ty-272811.appspot.com/'; //$config['base_url'] = 'https://wbt-2-ty-272811.appspot.com/';
//$config['base_url'] = 'http://localhost/webapp/ci/'; $config['base_url'] = 'http://localhost/webapp/ci/';
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -379,22 +379,22 @@ $config['encryption_key'] = 'femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC'; ...@@ -379,22 +379,22 @@ $config['encryption_key'] = 'femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC';
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here. | except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
| |
*/ */
$config['sess_driver'] = 'memcached'; //$config['sess_driver'] = 'memcached';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'localhost:11211';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = FALSE;
//$config['sess_driver'] = 'database';
//$config['sess_cookie_name'] = 'ci_session'; //$config['sess_cookie_name'] = 'ci_session';
//$config['sess_expiration'] = 7200; //$config['sess_expiration'] = 7200;
//$config['sess_save_path'] = 'ci_sessions'; //$config['sess_save_path'] = 'localhost:11211';
//$config['sess_match_ip'] = FALSE; //$config['sess_match_ip'] = FALSE;
//$config['sess_time_to_update'] = 7200; //$config['sess_time_to_update'] = 7200;
//$config['sess_regenerate_destroy'] = FALSE; //$config['sess_regenerate_destroy'] = FALSE;
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = FALSE;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Cookie Related Variables | Cookie Related Variables
...@@ -466,7 +466,7 @@ $config['csrf_regenerate'] = false; ...@@ -466,7 +466,7 @@ $config['csrf_regenerate'] = false;
$config['csrf_exclude_uris'] = array( $config['csrf_exclude_uris'] = array(
'cart/add_to_cart', 'cart/load_cart', 'cart/add_to_cart', 'cart/load_cart',
'home/products', 'cart/delete_product_from_cart', 'cart/increase_qty', 'cart/decrease_qty', 'home/products', 'cart/delete_product_from_cart', 'cart/increase_qty', 'cart/decrease_qty',
'auth/resetpassword' 'auth/resetpassword','auth/email_availability'
); );
......
...@@ -75,12 +75,12 @@ $query_builder = TRUE; ...@@ -75,12 +75,12 @@ $query_builder = TRUE;
$db['default'] = array( $db['default'] = array(
'dsn' => '', 'dsn' => '',
'hostname' => '104.199.82.156', // 'hostname' => '104.199.82.156',
'username' => 'tetiana', // 'username' => 'tetiana',
'password' => 'yaremko_tetiana', // 'password' => 'yaremko_tetiana',
// 'hostname' => 'localhost', 'hostname' => 'localhost',
// 'username' => 'root', 'username' => 'root',
// 'password' => '', 'password' => '',
'database' => 'mydb', 'database' => 'mydb',
'dbdriver' => 'mysqli', 'dbdriver' => 'mysqli',
'dbprefix' => '', 'dbprefix' => '',
......
...@@ -262,6 +262,16 @@ class Auth extends CI_Controller ...@@ -262,6 +262,16 @@ class Auth extends CI_Controller
} }
public function email_availability() {
$this->load->model('Register_model', 'auth');
if($this->auth->is_email_available($_POST["email"])) {
echo '<label class="text-danger"><span class="glyphicon glyphicon-remove"></span> Email is already registered</label>';
} else {
echo '<label class="text-success"><span class="glyphicon glyphicon-add"></span> Email is available</label>';
}
}
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
$allowAll['auth']['resetpassword']=true; $allowAll['auth']['resetpassword']=true;
$allowAll['auth']['changepassword']=true; $allowAll['auth']['changepassword']=true;
$allowAll['auth']['verify'] =true; $allowAll['auth']['verify'] =true;
$allowAll['auth']['email_availability'] =true;
$allowAll['home']['products']=true; $allowAll['home']['products']=true;
$allowAll['cart']['add_to_cart']=true; $allowAll['cart']['add_to_cart']=true;
......
...@@ -71,6 +71,15 @@ class Register_model extends CI_Model { ...@@ -71,6 +71,15 @@ class Register_model extends CI_Model {
} }
function is_email_available($email) {
$this->db->where('email', $email);
$query=$this->db->get('users');
if($query->num_rows()>0) {
return true;
}
return false;
}
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<td> <td>
<input name="email" id="email" type="text" value="<?php echo set_value("email") ?>"> <input name="email" id="email" type="text" value="<?php echo set_value("email") ?>">
<?php echo $error; ?> <?php echo $error; ?>
<span id="email_result"></span>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
<td> <td>
<input name="password" id="password" type="password"> <input name="password" id="password" type="password">
<?php echo $error; ?> <?php echo $error; ?>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -217,12 +219,40 @@ ...@@ -217,12 +219,40 @@
</div> </div>
<!-- Optional JavaScript --> <!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS --> <!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="<?php echo base_url();?>assets/js/bootstrap.min.js"></script> <script src="<?php echo base_url();?>assets/js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>asset/js/jquery-3.3.1.min.js"></script>
<script>
base_url = '<?php echo base_url(); ?>';
$(document).ready(function() {
$('#email').change(function() {
var email=$('#email').val();
if(email!='')
{
$.ajax({
url: base_url+'index.php/auth/email_availability',
method: "POST",
data: {email:email},
success:function(data) {
$('#email_result').html(data);
}
})
}
})
})
</script>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment