我正在代码点火器中制作联系人表格,但我不知道如何清除此错误?所以我试过了?今天只有我在使用codeigner。有人能帮我吗?我得到了错误:遇到PHP错误严重程度:通知消息:使用未定义的常量"contact_form"™ -假定为"contact_form"™'文件名:controllers/contact.php行号:33IN应用程序控制器:
<?php
class contact extends ci_controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$mail_sent = false;
if ($this->input->post("q"))
{
// Loading email library of Codeigniter
$this->load->library(‘email’);
// Loading configuration file mail_config.php
$this->config->load(‘mail_config’,true);
// Setting email address and name of the person sending the email
$this->email->from($this->input->post("from"),$this->input->post("name"));
// Setting email address of the recipient
$this->email->to($this->config->item(‘to’,’mail_config’));
// Setting email subject
$this->email->subject($this->input->post("subject"));
// Setting email message body
$this->email->message($this->input->post("message",true));
// If mail sending successful
if ($this->email->send())
{
// If $mail_sent = true; it will show a success message.
$mail_sent = true;
}
}
$this->load->view(‘contact_form’,array(‘mail_sent’=>$mail_sent));
}
}
?>
视图中:我创建了contact_form.php
<?php
if ($mail_sent):
?>
<b>Mail Sent</b>
<?php
endif;
?>
<form action="<?php echo base_url() ?>" method="POST">
<b>Your Name :</b>
<br />
<input type="text" name="name" value=""/>
<br />
<b>Your Email Address:</b>
<br />
<input type="text" name="from" value=""/>
<br />
<b>Subject :</b>
<br />
<input type="text" name="subject" value=""/>
<br />
<b>Message :</b>
<br />
<textarea name="message" rows="10" cols="15"></textarea>
<br />
<input type="submit" name="q" value="Contact" />
</form>
您使用了错误的字符,请将‘
替换为'
。