Php 如何在模板中获取表单值
我想在表单模板文件中呈现$\u POST值。表单正在重定向到同一页,但我不确定如何将值呈现到模板文件 表格:Php 如何在模板中获取表单值,php,html,forms,cakephp-1.3,Php,Html,Forms,Cakephp 1.3,我想在表单模板文件中呈现$\u POST值。表单正在重定向到同一页,但我不确定如何将值呈现到模板文件 表格: <form method="POST" name="requestform" action="" id="tour_request_form"> <h4>Number of Passengers:</h4> <input type="hidden" name="tour_name" value="{{ tourDat
<form method="POST" name="requestform" action="" id="tour_request_form">
<h4>Number of Passengers:</h4>
<input type="hidden" name="tour_name" value="{{ tourData.title }}"/>
<div id="request_form_row">
<label> Adults:
<select id="adult_passengers" name="adult_passengers" required>
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</label>
</div>
<div id="request_form_row">
<button type="submit">Send Request</button>
</div>
</form>
在Messenger组件中,我有:
public function sent_mail($data = array()) {
if(empty($data)) {
return false;
}
$this->Email->to = $data["to"];
if(!empty($data["cc"])) {
$this->Email->cc = explode(",", $data["cc"]);
}
$this->Email->from = $data["from"];
$this->Email->subject = $data["subject"];
$this->Email->template = "request_form";
$this->Email->layout = "request_form";
$this->Email->sendAs = "html";
$this->controller->set("message", $data["body"]);
return $this->Email->send();
}
我只是想知道如何将表单数据呈现到模板?
表绳波纹管
$this->set($first\u name',$first\u name)
您可以通过如上所述设置值来传递值,并可以将其作为变量调用。您正在引用控制器和组件。您使用的框架中是否有您没有提到的内容?@PatrickM是的,我使用的是CakePHP-很抱歉没有提及。
public function sent_mail($data = array()) {
if(empty($data)) {
return false;
}
$this->Email->to = $data["to"];
if(!empty($data["cc"])) {
$this->Email->cc = explode(",", $data["cc"]);
}
$this->Email->from = $data["from"];
$this->Email->subject = $data["subject"];
$this->Email->template = "request_form";
$this->Email->layout = "request_form";
$this->Email->sendAs = "html";
$this->controller->set("message", $data["body"]);
return $this->Email->send();
}