Web サイトにユーザーが入力するフォームがあります。フォームの検証後、値が入力されたままそのフォームをメール (HTML フォームまたは PDF など) に送信したいと考えています。 Php または Codeigniter を使用してフォームを送信する際に、フォームを HTML フォームまたは Pdf として送信する方法がわかりません。
質問する
317 次
4 に答える
1
これを試して:
#post your HTML form in a view say form.php
public function sendForm(){ #the controller function
if($this->input->post(null)){
$postValues = $this->input->post(null); #retrieve all the post variables and send to form.php
$form = $this->load->view('form.php', $postValues, true); #retrieve the form as HTML and send via email
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->subject('Email Test');
$this->email->message($form);
$this->email->send();
}
}
于 2013-07-19T07:40:29.553 に答える
0
これは CI のEmail Classを使えばとても簡単です。
投稿を処理するだけで、新しいビューを作成してフォームデータを渡すことができます
$this->email->initialize($config);
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test');
$data['form_post'] = $this->input->post();
$msg = $this->load->view('email/template',$data,true);
$this->email->message($msg);
$this->email->alt_message('Something Should go here Else CI just takes the original and strips the tags');
$this->email->send();
于 2013-07-19T07:39:57.170 に答える