Welcome Guest, Not a member yet? Register   Sign In
submit button not redirecting

I'm trying to make a simple codeigniter signup form, but when I press the submit button nothing happens. Not sure what is going wrong. please help. I've posted both my view file and the contoller which i am re-directing in the form.

<div id="newsletter_form">
   Sign up to our newsletter

   echo form_open('email/send');


   $name_data= array('name'=>'name',
       'value'=> set_value('name')


   <p> <label for=" name"> Name :</label> <?php echo form_input($name_data); ?> </p>  <!--form_input acts like input tag-->

   <p> <label for=" email"> email address:</label>
       <input type="email" name="email" id="email" value="<?php echo set_value('email') ?>" required/> </p>

   <p> <?php echo form_submit('submit','submit');?></p>

   <?php echo form_close(); ?>

And the below one is my email.php file


class email extends CI_Controller
   function _construct()

   function index()

   function send()
       echo "hello";

       $this->email->from('[email protected]', 'pallavi');
       $this->email->to('[email protected]');
       $this->email->message('hello gpks');

       $path = $this->config->item('server_root');  //server_root is set to document root in config.php
       //echo $path; //to make sure path is set to doc root

       $file = $path . '/CI/attachment/hello.txt';

       if ($this->email->send()) {
           echo "your mail was sent";
       } else {

Well, given what you've posted here:

- The controller's class and file name should start with an uppercase letter "Email" and "Email.php"
- The constructor should be:

PHP Code:
public function __construct()

(note that it starts with two underscores (__), not one.

- You shouldn't echo from your controller, especially right at the beginning of your send() method, since this may prevent some or all of the code after the echo from executing properly and will eventually cause errors if you try to load a view.
- I'm assuming you just stopped copying the code at whatever point you thought was relevant, as you don't have closing braces for either the send() method or the class.


I did try the constructor, but it doesnt work,if i run email.php the the view gets loaded but the submit isnt redirected.  
The send function also works when i run separately. 
But the form submit doesnt work. (it doesnt redirect to the send function)

I have tried the constructor part. but it didnt work either.

In my file email.php the view gets loaded but the submit doesnt redirected to send method in contoller. Also the send method works fine separately.

PHP Code:
class email extends CI_Controller
//should be
class Email extends CI_Controller    // save as: ../application/controllers/Email.php 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

You probably need to use a different name for your controller. When you load the Email library from an Email controller, it's probably not going to work out very well.

Tried with both Email and a different name. 

But nothing changed Confused Sad

Could you post your complete code for Controller and view files.

I have attached both the files.

Attached Files
.php   newsletter_view.php (Size: 936 bytes / Downloads: 95)
.php   Blog.php (Size: 1,011 bytes / Downloads: 92)

(This post was last modified: 11-12-2015, 01:10 AM by pdthinh.)

(11-11-2015, 09:02 PM)[email protected] Wrote: I have attached both the files.

In your view file modify this line:
PHP Code:
   echo form_open("blog/send"); // blog starts with lower case letter 

In the controller you can use simplified send() method to test if the view can submit to it:
PHP Code:
   function send()

Theme © iAndrew 2016 - Forum software by © MyBB