Codeigniter 404 Page Not Found in Signup form


Codeigniter 404 Page Not Found in Signup form



I just created my sign up form with email verification but it's giving me error "404 Page Not Found" when I click on Sign up button?
Here is my view named as sign_up:


404 Page Not Found


<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Registeration</title>
<!-- CSS -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
<link rel="stylesheet" href="<?php echo base_url();?>assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/form-elements.css">
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js
https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js
<![endif]-->

<!-- Favicon and touch icons -->

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php echo base_url();?>assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo base_url();?>assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo base_url();?>assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="<?php echo base_url();?>assets/ico/apple-touch-icon-57-precomposed.png">

</head>

<body>

<!-- Top menu -->
<nav class="navbar navbar-inverse navbar-no-bg" role="navigation">



<!-- Collect the nav links, forms, and other content for toggling -->

</div>
</nav>

<!-- Top content -->






Register Here






</div>

</div>



Sign up now


Fill in the form below to get instant access:






</div>

"registrationform");
echo form_open("Register/reg", $attributes);?>


Full Name
" placeholder="Full Name..." class="form-first-name form-control" id="name" required>



Email
" placeholder="Email..." class="form-email form-control" id="email" required>




Password




Confirm Password



<button type="submit" class="btn">Sign me up!</button>
<button type="reset" class="btn">Cancel!</button>
<?php echo form_close(); ?>
<?php echo $this->session->flashdata('msg'); ?>
</div>
</div>
</div>
</div>
</div>

</div>


<!-- Javascript -->
?php%20echo%20base_url();?assets/js/jquery-1.11.1.min.js
?php%20echo%20base_url();?assets/bootstrap/js/bootstrap.min.js
?php%20echo%20base_url();?assets/js/jquery.backstretch.min.js
?php%20echo%20base_url();?assets/js/retina-1.1.0.min.js
?php%20echo%20base_url();?assets/js/scripts.js

<!--[if lt IE 10]>
http://assets/js/placeholder.js
<![endif]-->

</body>

</html>



here is controller named as Register:


<?php
class Register extends CI_Controller
{

function index()
{
$this->reg();

}

function reg()
{
//set validation rules
$this->form_validation->set_rules('name', 'Full Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[users.email]');
$this->form_validation->set_rules('password', 'Password', 'trim|required|matches[cpassword]|md5');
$this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required');
$this->load->view('Seller/login');
//validate form input
if ($this->form_validation->run() == FALSE)
{
// fails
$this->load->view('sign_up');
}
else
{
//insert the user registration details into database
$data = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'password' => $this->input->post('password')
);

// insert form data into database
if ($this->Seller_model->insertUser($data))
{
// send email
if ($this->Seller_model->sendEmail($this->input->post('email')))
{
// successfully sent mail
$this->session->set_flashdata('msg','

You are Successfully Registered! Please confirm the mail sent to your Email-ID!!!
');
redirect('Register/reg');
}
else
{
// error
$this->session->set_flashdata('msg','
Oops! Error. Please try again later!!!
');
redirect('Register/reg');
}
}
else
{
// error
$this->session->set_flashdata('msg','
Oops! Error. Please try again later!!!
');
redirect('Register/reg');
}
}
}

function verify($hash=NULL)
{
if ($this->Seller_model->verifyEmailID($hash))
{
$this->session->set_flashdata('verify_msg','
Your Email Address is successfully verified! Please login to access your account!
');
redirect('Register/reg');
}
else
{
$this->session->set_flashdata('verify_msg','
Sorry! There is error verifying your Email Address!
');
redirect('Register/reg');
}
}
}
?>



here is model named Seller_model:


<?php
class Admin_model extends CI_Model{
function __construct()
{
// Call the Model constructor
parent::__construct();
}

//insert into user table
function insertUser($data)
{
return $this->db->insert('users', $data);
}

//send verification email to user's email id
function sendEmail($to_email)
{
$from_email = 'team@abc.com'; //change this to yours
$subject = 'Verify Your Email Address';
$message = 'Dear User,<br /><br />Please click on the below activation link to verify your email address.<br /><br /> anywebsite/user/verify/' . md5($to_email) . '<br /><br /><br />Thanks<br />` `Mydomain Team';

//configure email settings
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.mydomain.com'; //smtp host name
$config['smtp_port'] = '465'; //smtp port number
$config['smtp_user'] = $from_email;
$config['smtp_pass'] = '********'; //$from_email password
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "rn"; //use double quotes
$this->email->initialize($config);

//send mail
$this->email->from($from_email, 'Mydomain');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
return $this->email->send();
}

//activate user account
function verifyEmailID($key)
{
$data = array('status' => 1);
$this->db->where('md5(email)', $key);
return $this->db->update('user', $data);
}
}?>



Here is routes:


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| https://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are three reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
| $route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'Seller';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;





Please include your routes or routing table. A 404 page is usually a sign that the URL you are accessing is incorrect. Also, search StackOverflow as many users have had this same issue.
– Aaron Franco
Apr 6 '16 at 11:37





#Aaron I have added routes.
– Bakhtawar
Apr 6 '16 at 11:49




1 Answer
1



I suspect you don't use the mod_rewrite so you must create urls in this way index.php?/Register/reg. Read about mod_rewrite if you use apache and how to make pretty urls.


index.php?/Register/reg






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift