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.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Smile Adding Email Values Error

    I can not seem to get my form values correct every time I put them in my views part it stops page from working and makes also the place holders not show either what is the way to link it up with my controller file I use codeigniter .

    Code:
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    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());
    		}
    
    	}
    
    }
    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>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,354
    Thanks
    23
    Thanked 618 Times in 617 Posts
    Code:
    <form role="form" method="post" action="http:/www.yourdomain.com/contact/send">
    
    <div class="form-group">Name :
    <label for="name"></label>
    <input type="text" class="form-control" id="name" placeholder="Enter Name">
    </div> ....
    What is 'role'? I would remove that and give the form an ID, id="MyFrom".

    You then give your <input>s IDs. NO, give them 'name's. example name='full_name'. That's how the action program will find them
    'full_name', because I hate using tags and attributes like this.

    Your action="http:/www.yourdomain.com/contact/send" should be a PHP file and needs that extension so the server will recognize it. action="http:/www.yourdomain.com/contact/send.php"

    May not clear up all the problems but it's a start.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    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
    •