我想在 cakephp 中制作一个验证表单,我的代码表单是:
看法
<div class="well">
<?php
echo $this->Form->create(false);
echo $this->Form->input('name', array('label' => 'name '));
echo $this->Form->input('PHONE_NUMBER', array('label' => 'PHONE_NUMBER '));
echo $this->Form->input('EMAIL', array('label' => 'EMAIL '));
echo $this->Form->input('ISSUE', array('label' => 'ISSUE '));
echo $this->Form->input('IP', array('label' => 'IP '));
echo $this->Form->submit('Send.');
?>
控制器
<?php
class ContactController extends AppController {
public function index() {
if (empty($_POST) === FALSE) {
$message = '';
$message .=$_POST['data']['EMAIL'] . ' <br/>';
$message .=$_POST['data']['name'] . ' <br/>';
$message .=$_POST['data']['PHONE_NUMBER'] . ' <br/>';
$message .=$_POST['data']['ISSUE'] . ' <br/>';
$message .=$_SERVER['REMOTE_ADDR'] . ' <br/>';
mail('mohmed@lcegy.com', 'Support From Website ', $message);
$this->Session->setFlash("Thanks , an email just sent .");
}
}
}
我的问题是如何以这种形式实现验证以及如何获取访问者的 IP 地址?