Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
tetiana yaremko
/
web-app-group2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6a7343ad
authored
May 04, 2020
by
tetiana yaremko
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
email availability using ajax in registration form
parent
52da0056
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
19 deletions
application/config/config.php
application/config/database.php
application/controllers/Auth.php
application/hooks/acl.php
application/models/Register_model.php
application/views/register.php
application/config/config.php
View file @
6a7343ad
...
...
@@ -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.
|
*/
$config
[
'base_url'
]
=
'https://wbt-2-ty-272811.appspot.com/'
;
//
$config['base_url'] = 'http://localhost/webapp/ci/';
//
$config['base_url'] = 'https://wbt-2-ty-272811.appspot.com/';
$config
[
'base_url'
]
=
'http://localhost/webapp/ci/'
;
/*
|--------------------------------------------------------------------------
...
...
@@ -379,22 +379,22 @@ $config['encryption_key'] = 'femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC';
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
$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_driver'] = 'memcached';
//$config['sess_cookie_name'] = 'ci_session';
//$config['sess_expiration'] = 7200;
//$config['sess_save_path'] = '
ci_sessions
';
//$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_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
...
...
@@ -466,7 +466,7 @@ $config['csrf_regenerate'] = false;
$config
[
'csrf_exclude_uris'
]
=
array
(
'cart/add_to_cart'
,
'cart/load_cart'
,
'home/products'
,
'cart/delete_product_from_cart'
,
'cart/increase_qty'
,
'cart/decrease_qty'
,
'auth/resetpassword'
'auth/resetpassword'
,
'auth/email_availability'
);
...
...
application/config/database.php
View file @
6a7343ad
...
...
@@ -75,12 +75,12 @@ $query_builder = TRUE;
$db
[
'default'
]
=
array
(
'dsn'
=>
''
,
'hostname'
=>
'104.199.82.156'
,
'username'
=>
'tetiana'
,
'password'
=>
'yaremko_tetiana'
,
//
'hostname' => 'localhost',
//
'username' => 'root',
//
'password' => '',
//
'hostname' => '104.199.82.156',
//
'username' => 'tetiana',
//
'password' => 'yaremko_tetiana',
'hostname'
=>
'localhost'
,
'username'
=>
'root'
,
'password'
=>
''
,
'database'
=>
'mydb'
,
'dbdriver'
=>
'mysqli'
,
'dbprefix'
=>
''
,
...
...
application/controllers/Auth.php
View file @
6a7343ad
...
...
@@ -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>'
;
}
}
...
...
application/hooks/acl.php
View file @
6a7343ad
...
...
@@ -12,6 +12,7 @@
$allowAll
[
'auth'
][
'resetpassword'
]
=
true
;
$allowAll
[
'auth'
][
'changepassword'
]
=
true
;
$allowAll
[
'auth'
][
'verify'
]
=
true
;
$allowAll
[
'auth'
][
'email_availability'
]
=
true
;
$allowAll
[
'home'
][
'products'
]
=
true
;
$allowAll
[
'cart'
][
'add_to_cart'
]
=
true
;
...
...
application/models/Register_model.php
View file @
6a7343ad
...
...
@@ -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
;
}
...
...
application/views/register.php
View file @
6a7343ad
...
...
@@ -44,6 +44,7 @@
<td>
<input
name=
"email"
id=
"email"
type=
"text"
value=
"
<?php
echo
set_value
(
"email"
)
?>
"
>
<?php
echo
$error
;
?>
<span
id=
"email_result"
></span>
</td>
</tr>
<tr>
...
...
@@ -54,6 +55,7 @@
<td>
<input
name=
"password"
id=
"password"
type=
"password"
>
<?php
echo
$error
;
?>
</td>
</tr>
<tr>
...
...
@@ -217,12 +219,40 @@
</div>
<!-- Optional JavaScript -->
<!-- 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://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=
"
<?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>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment