Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Smile Redirect Email Page After Sent

    Hi I have been working on a contact form page I have got back end done but just need my “if else to work” I use codeigniter.

    Code:
    $this->load->library('email');
    
    $this->email->set_newline("\r\n");
    
    $this->email->from('example@example.com', 'Website');
    $this->email->to('example@example.com');
    
    $this->email->subject('This is a test Email');
    $this->email->message('This Is Only Demo Message');
    <!-- Need This To Be Directed To Another Page -->
    if($this->email->send()) {
        $this->load->view('contact_sent');
    }
    else {
        show_error($this->email->print_debugger());
    }

  • #2
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    What does this do?
    $this->load->view('contact_sent');

    Have you looked here?
    http://ellislab.com/codeigniter/user...ies/email.html

    Try this way?
    Edit:
    PHP Code:
    if($this->email->send()) { echo 'Your email was sent!';
     } else {
     
    show_error($this->email->print_debugger());
     } 
    [

    You could try
    PHP Code:
    $mailsent $this->email->send();
    if (
    $mailsent){
    #...do something or show sent
    echo "sent";
    }else{
    #...get the error
    show_error($this->email->print_debugger());


    How to send email using php codeigniter
    Last edited by student101; 10-14-2013 at 05:00 PM. Reason: untested
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #3
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    I have a separate landing page for contact from after email sent. I use codeigniter hmvc

    application / modules / contact /

    application / modules / contact / controllers / contact.php

    application / modules / contact / controllers / contact_sent.php

    application / modules / contact / views / contact.php

    application / modules / contact / views / contact_sent.php

    Just need it to redirect to the views contact_sent.php after press send button. but at the moment it is like that for testing so make sure it can work

  • #4
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    great!
    How does this $this->load->view('contact_sent'); work?
    Have you tried loading any of those pages with a link / button without your email code?

    Edit: Have you loaded the external function?
    Could you post errors as well please.
    Last edited by student101; 10-14-2013 at 05:18 PM.
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #5
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    don't worry about it will have to hunt around some more

  • #6
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    Quote Originally Posted by vipercode View Post
    don't worry about it will have to hunt around some more
    What errors have you received?
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #7
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    As I said before in first comment.

    I would like to make a link in my controller that would send my viewer to another page after click send/submit button


    Code:
    $this->load->library('email');
    
    $this->email->set_newline("\r\n");
    
    $this->email->from('example@example.com', 'Website');
    $this->email->to('example@example.com');
    
    $this->email->subject('This is a test Email');
    $this->email->message('This Is Only Demo Message');
    <!-- Some How Send it to this link $this->load->view('contact_sent'); after viewer clicks send/submit button-->

  • #8
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    Does this $this->load->view('redirect_page'); work on any other page on your site?

    I'm trying to understand how your MVC is setup

    Edit: I'm using this as a reference
    Application Flow Chart

    redirect, redirects you to a different URL.
    $this->load->view() loads a view but you should still be in the same URL.

    Which allows you the option to load different views in a method.

    Have you tried redirect?
    redirect(site_url('redirect_page'));
    If you don't wanna use site_url() then hard code the URL in like redirect('http://www.example.com/redirect_page.php');
    Last edited by student101; 10-14-2013 at 11:29 PM. Reason: typos
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • Users who have thanked student101 for this post:

    riwakawd (10-15-2013)

  • #9
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Will play around with it see how I go

  • #10
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    This way works for me I have got it going now. just working on values now

    Code:
    class Contact extends MX_Controller {
    
    	function index() {
    
    		$this->load->view('header');
    		$this->load->view('contact');
    		$this->load->view('footer');
    
    	}
    
    
    	function send() {
    
    		$this->load->library('email');
    
    		$this->email->set_newline("\r\n");
    
    		$this->email->from('example@yourdomain.com', 'Website');
    		$this->email->to('example@yourdomain.com');
    
    		$this->email->subject('This is a test Email');
    		$this->email->message('This Is Only Demo Message');
    
    		if($this->email->send()) {
    
    			$this->load->view('header');
    			$this->load->view('contact_sent');
    			$this->load->view('footer');
    		}
    		else {
    			show_error($this->email->print_debugger());
    		}
    
    	}
    
    }

  • #11
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts

    Thumbs up

    Quote Originally Posted by vipercode View Post
    This way works for me I have got it going now. just working on values now
    Glad you sorted!
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #12
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    Where are you getting this from?
    It looks like you have a problem with connecting to your controller, the part that's supposed to make this work $this->load->view('redirect_page');

    need more info...
    What did you try?
    What did you get?
    What did you expect to get?
    PHP Code:
    Input -> Controller Processing -> Model Output -> View 

    Quote Originally Posted by vipercode View Post
    Hi I have been working on a contact form page I have got back end done but just need my “if else to work” I use codeigniter.

    Code:
    $this->load->library('email');
    
    $this->email->set_newline("\r\n");
    
    $this->email->from('example@example.com', 'Website');
    $this->email->to('example@example.com');
    
    $this->email->subject('This is a test Email');
    $this->email->message('This Is Only Demo Message');
    <!-- Need This To Be Directed To Another Page -->
    if($this->email->send()) {
        $this->load->view('contact_sent');
    }
    else {
        show_error($this->email->print_debugger());
    }
    Last edited by student101; 10-15-2013 at 08:30 AM.
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #13
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Smile

    On this one all i did as you see compared to other one I have created two functions rather than one. function send()

    Code:
    class Contact extends MX_Controller {
    
    	function index() {
    
    		$this->load->view('header');
    		$this->load->view('contact');
    		$this->load->view('footer');
    
    	}
    
    
    	function send() {
    
    		$this->load->library('email');
    
    		$this->email->set_newline("\r\n");
    
    		$this->email->from('example@yourdomain.com', 'Website');
    		$this->email->to('example@yourdomain.com');
    
    		$this->email->subject('$subject');
    		$this->email->message('$message');
    
    		if($this->email->send()) {
    
    			$this->load->view('header');
    			$this->load->view('contact_sent');
    			$this->load->view('footer');
    		}
    		else {
    			show_error($this->email->print_debugger());
    		}
    
    	}
    
    }
    Question. I am stuck now on the form side I have created the form part but don't know to get code working. linked with form. I need it so it can also pick up mu subject on form. you have any idea you can see I have change the message and the subject on the controller side

    Code:
    <form role="form" method="post" action="http:/www.yourdomain.com/contact/send">
    <div class="form-group">
    <label for="name"></label>
    <input type="text" class="form-control" id="name" placeholder="Enter Name">
    </div>
    <div class="form-group">
    <label for="email"></label>
    <input type="text" class="form-control" id="email" placeholder="Enter Email">
    </div>
    <div class="form-group">
    <select  class="form-control" id="subject" name="subject">
    <option value="na" selected="">Choose One:</option>
    <option value="service">Feedback</option>
    <option value="suggestions">Suggestion</option>
    <option value="support">Question</option>
    <option value="other">Other</option>
    </select>
    </div>
    <div class="form-group">
    <textarea type="text" class="form-control" rows="4" placeholder="Message" name="message"></textarea>
    </div>
    <div id="success"> </div> <!-- For success/fail messages -->
    <div class="pager">
    <button type="submit" class="btn btn-primary">Submit</button>
    <button type="reset" class="btn btn-danger">Reset</button>
    </div>
    </form>

  • #14
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    Is this site live / available online?

    Edit: is there a tutorial you following?
    Last edited by student101; 10-15-2013 at 09:30 AM.
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #15
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Smile

    http://www.carrarawebsitesolutions.com/contact

    I use to be able to do it standard html with no php but moved to codeigniter I am self teaching have been watching lot of videos Like Non NetTuts


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •