做的第一个例子出了问题 。。。内牛满面
控制器 welcome.phpclass Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index(){
$this->load->helper('form');
$data['title'] = "Welcome to our Site";
$data['headline'] = 'Welcome';
$data['include'] = 'home';
$this->load->vars($data);
$this->load->view('template');
}
模型 mcontacts.php
class Mcontacts extends Model{
function Mcontacts(){
parent::Model();
}
}
function addContact(){
$now = date("Y-m-d H:i:s");
$date= array('name'=>$this->input->xss_clean($this->input->post('name')),
'email'=>$this->input->xss_clean($this->input->post('email')),
'notes' =>$this->input->xss_clean($this->input->post('notes')),
'ipaddress' =>$this->input->ip_address(),
'stamp'=>now());
$this->db->insert('test',$date);
}
视图template.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $title;?></title>
<style>label { display:block;}</style>
</head>
<body>
<h1><?php echo $headline;?></h1>
<?php $this->load->view($include);?>
</body>
</html>
home.php
<p>This is random text for the CodeIgniter article.
There's nothing to see here folks, just move along!</p>
<h2>Contact Us</h2>
<?php
echo form_open('welcome/contactus');
echo form_label('your name','name');
$ndata = array('name' => 'name', 'id' => 'id', 'size' => '25');
echo form_input($ndata);
echo form_label('your email','email');
$edata = array('name' => 'email', 'id' => 'email', 'size' => '25');
echo form_input($edata);
echo form_label('how can you help you?','notes');
$cdata = array('name' => 'notes', 'id' => 'notes', 'cols' => '40', 'rows' => '5');
echo form_textarea($cdata);
echo form_submit('submit','send us a note');
echo form_close();
?>
问题是 我提交的时间找不到welcome/contactus 请高手帮解决下 function contactus()呢? 不知道那断程序放那 所以才内牛满面 要在 Welcome 控制器中创建一个 contactus 方法。
仔细阅读 http://codeigniter.org.cn/user_guide/general/controllers.html
每一个字节都要看。 Welcome 控制器中创建一个 contactus 方法
我创建了 也没找到 我在写写看看 :'( 刚接触 学习中···
页:
[1]