email issue , probably simple :)

#1
[eluser]DynamiteN[/eluser]
Hi i have a contact form where a user fill in different things in different boxes

the problem i have is i dont know how to get all of those input values from that form
into the message

like i have two fields named "nick" and "name"
and then i there is subject and the message it self,

now how to i get those "nick" and "name" passed into the mail as well
maybe write to a file it somehow ? i tried with write_file(); but then it wont work with an array apperantly, anyone knows how to do this,

there is actually a few more fields then just those two but if anyone could point me in a direction here im sure i can figure something out Smile

//DynamiteN

#2
[eluser]DynamiteN[/eluser]
anyone ? please Smile

been struggeling with this issue a while now ...

#3
[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...input.html

Is the problem that you don't understand how PHP interacts with HTML forms, or that you don't understand how CI interacts with POST data?

#4
[eluser]DynamiteN[/eluser]
Code:
class Contact extends Controller{
function send() {
        
        // field name, error message, validation rules
        $this->form_validation->set_rules('nick', 'Nick', 'trim|required');
        $this->form_validation->set_rules('name', 'Name', 'trim|required');
        $this->form_validation->set_rules('steam_id', 'Steam ID', 'trim|required');
        $this->form_validation->set_rules('email', 'E-mail', 'trim|required|valid_email');
        $this->form_validation->set_rules('subject', 'Subject', 'trim|required');
        $this->form_validation->set_rules('message', 'Message', 'trim|required');


        if($this->form_validation->run() == FALSE) {
                $vars['title'] = 'Contact';
                $vars['content_view'] = 'contact_view';
                $vars['container_css'] = 'container';
                $this->load->view('template', $vars);
            
            }else{
            
            // validation has passed. Now send the email
            $nick = $this->input->post('nick');
            $name = $this->input->post('name');
            $steamid = $this->input->post('steam_id');
            $email = $this->input->post('email');
            $subject = $this->input->post('subject');
            $message = $this->input->post('message');
            

            
            $this->load->library('email');
            $this->email->set_newline("\r\n");

            $this->email->from('[email protected]', 'Contact Elegance');
            $this->email->to('[email protected]');        
            $this->email->subject($subject);        
            $this->email->message($message);
            
            $path = $this->config->item('server_root');
            $file = $path . '/attachements/contact_info.txt';
            
            $this->email->attach($file);
            
            
            if($this->email->send())
            {
                $vars['title'] = 'Contact';
                $vars['content_view'] = 'contact_submitted';
                $vars['container_css'] = 'container';
                $vars['message'] = 'Thank you, a respons will be sent within 48h.';
                $this->load->view('template', $vars);
            }

            else
            {
                show_error($this->email->print_debugger());
            }            
        }
    }
}

this is t he code in the controller it works just fine but i would like to pass in those others input fields in to the mail, the message and the subject works jsut fien and mailing works jsut fine, but how to send these fields to

Code:
$nick = $this->input->post('nick');
$name = $this->input->post('name');
$steamid = $this->input->post('steam_id');
$email = $this->input->post('email');

i dont know how to get this in to the mail as well , maybe attach a file as i have done there and somehow pass the data from these inputs in to that file,

hope u understand my problem better now

#5
[eluser]DynamiteN[/eluser]
anyone ? been googeling this every day still cant find an answer how to do this :/

#6
[eluser]heavenquake[/eluser]
how about this solution:
Code:
// validation has passed. Now send the email
            $nick = $this->input->post('nick');
            $name = $this->input->post('name');
            $steamid = $this->input->post('steam_id');
            $email = $this->input->post('email');
            $subject = $this->input->post('subject');
            $message = $this->input->post('message');
            $message = 'Nick: ' . $nick . PHP_EOL . 'Name: ' . $name . PHP_EOL . PHP_EOL . $message;

?

#7
[eluser]DynamiteN[/eluser]
[quote author="heavenquake" date="1266725850"]how about this solution:
Code:
// validation has passed. Now send the email
            $nick = $this->input->post('nick');
            $name = $this->input->post('name');
            $steamid = $this->input->post('steam_id');
            $email = $this->input->post('email');
            $subject = $this->input->post('subject');
            $message = $this->input->post('message');
            $message = 'Nick: ' . $nick . PHP_EOL . 'Name: ' . $name . PHP_EOL . PHP_EOL . $message;

?[/quote]

hmm , interesting , i will check it out , all though i am curious about this line
Code:
$message = 'Nick: ' . $nick . PHP_EOL . 'Name: ' . $name . PHP_EOL . PHP_EOL . $message;


EDIT: Tried it now, it worked :O ,
now im gonna go google PHP_EOL Big Grin

Thank you ALOT
what does that PHP_EOL do ?

i will try it now anyway Smile

#8
[eluser]DynamiteN[/eluser]
This worked just as well , thank you so much never heard about PHP_EOL (End Of Line) before until now Smile
Code:
$nick = $this->input->post('nick');
$name = $this->input->post('name');
$steamid = $this->input->post('steam_id');
$email = $this->input->post('email');
$subject = $this->input->post('subject');
$message = $this->input->post('message');
            
$contact = "Nick: $nick
Name: $name
SteamID: $steamid
E-mail: $email";
$message = $contact . PHP_EOL . PHP_EOL . $message;

#9
[eluser]heavenquake[/eluser]
It's great that it worked out for you!

PHP_EOL is whatever the operating system the app is running on uses for linebreaks.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.