Created
August 17, 2013 13:30
-
-
Save MichaelObi/6256859 to your computer and use it in GitHub Desktop.
controller for signup. Gcm tutorial -CodeIndulge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/***************************************************************************************************************** | |
* Signup details are recieved and sent to users_model from here. | |
* Signup results are recieved and actions are triggered from this controller. | |
* Validation status codes: when success = 1, Signup succeeds | |
*****************************************************************************************************************/ | |
class Signup extends CI_Controller { | |
public function auth() | |
{ | |
$data = $this->input->post(); | |
if( ($data['email'] == "") || ($data['password'] == "") || ($data['fname'] == "") || ($data['lname'] == "") || ($data['phone'] == "") ){ | |
$response['status'] = 'fail'; | |
$response['message'] = 'Please complete the form'; | |
} | |
else { | |
$signup = $this->users_model->Signup_user($data); | |
if($signup == 1){ | |
$response['status'] = 'fail'; | |
$response['message'] = 'Email already registered'; | |
} | |
elseif($signup == 0) { | |
$response['status'] = 'fail'; | |
$response['message'] = 'Wrong email or password'; | |
} | |
else{ | |
$response['status'] = "success"; | |
$response['message'] = "Authentication successful"; | |
$response['data']['uid'] = $signup['user_id']; | |
$response['data']['email'] = $signup['email']; | |
$response['data']['fname'] = $signup['fname']; | |
$response['data']['lname'] = $signup['lname']; | |
$response['data']['phone'] = $signup['phone']; | |
} | |
} | |
echo json_encode($response); | |
} | |
} | |
/* End of file Signup.php */ | |
/* Location: ./application/controllers/Signup.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment