I am developing an application in Codeigniter, My registration process involves users filling in there details which include an email address where after successful validation the user will be sent a verification code. This process works well but the only problem is when the user finishes the form and press register it loads and redirects to the login page without informing a user the code has been sent when it redirects to the login, how can I implement this? the below code is what I have so far
Auth .php
// action create user method
public function actionCreate() {
$this->form_validation->set_rules('first_name', 'First Name', 'required');
$this->form_validation->set_rules('last_name', 'Last Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[users.email]');
$this->form_validation->set_rules('contact_no', 'Contact No', 'required|regex_match[/^[0-9]{10}$/]');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[8]');
$this->form_validation->set_rules('confirm_password', 'Password Confirmation', 'trim|required|matches[password]');
$this->form_validation->set_rules('address', 'Address', 'required');
$this->form_validation->set_rules('dob', 'Date of Birth(DD-MM-YYYY)', 'required');
if ($this->form_validation->run() == FALSE) {
$this->register();
} else {
$firstName = $this->input->post('first_name');
$lastName = $this->input->post('last_name');
$email = $this->input->post('email');
$password = $this->input->post('password');
$contactNo = $this->input->post('contact_no');
$dob = $this->input->post('dob');
$address = $this->input->post('address');
$timeStamp = time();
$status = 0;
$verificationCode = uniqid();
$verificationLink = site_url() . 'signin?usid=' . urlencode(base64_encode($verificationCode));
$userName = $this->mail->generateUnique('users', trim($firstName . $lastName), 'user_name', NULL, NULL);
$this->auth->setUserName($userName);
$this->auth->setFirstName(trim($firstName));
$this->auth->setLastName(trim($lastName));
$this->auth->setEmail($email);
$this->auth->setPassword($password);
$this->auth->setContactNo($contactNo);
$this->auth->setAddress($address);
$this->auth->setDOB($dob);
$this->auth->setVerificationCode($verificationCode);
$this->auth->setTimeStamp($timeStamp);
$this->auth->setStatus($status);
$chk = $this->auth->create();
if ($chk === TRUE) {
$this->load->library('encryption');
$mailData = array('topMsg' => 'Hi', 'bodyMsg' => 'Congratulations, Your registration has been successfully submitted.', 'thanksMsg' => SITE_DELIMETER_MSG, 'delimeter' => SITE_DELIMETER, 'verificationLink' => $verificationLink);
$this->mail->setMailTo($email);
$this->mail->setMailFrom(MAIL_FROM);
$this->mail->setMailSubject('User Registeration!');
$this->mail->setMailContent($mailData);
$this->mail->setTemplateName('verification');
$this->mail->setTemplatePath('mailTemplate/');
$chkStatus = $this->mail->sendMail(MAILING_SERVICE_PROVIDER);
if ($chkStatus === TRUE) {
redirect('signin');
} else {
echo 'Error';
}
} else {
}
}
}
In your Register method before redirect to login
$this->session->set_flashdata('notify', 'Your code is sent');
redirect('auth/login');
in your login view - You can use Javascript with notifyJS or Bootstrap Notification to make design
if($this->session->flashdata('notify')){
echo $this->session->flashdata('notify');
}
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
CodeIgniter is a framework that is known for requiring a minimum amount of customization to get it up and running. This allows those who choose it to work at a good pace. It has been updated many times since its inception in 2006. Now the most recent version is 4.0.3.
https://www.codeigniter.com/
JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet.
https://www.javascript.com/
Bootstrap is not exclusively a CSS framework, but its most popular features are CSS-centric. These include a powerful grid, icons, buttons, map components, navigation bars, and more.
https://getbootstrap.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.