0
我有一個有趣的事情與我的本地開發設置進行。使用codeigniter我有一個窗體應該模擬存儲用戶在數據庫中的一些信息。在這一點上,我沒有數據庫設置,但我只希望表單在驗證完成時將我發送到成功頁面。但是當我提交表單時,它會回來,並告訴我名稱字段爲空,我從來沒有獲得成功頁面。我在這裏錯過了什麼嗎?請看看這個,並告訴我,如果我錯過了一些東西! 這是處理表單的控制器中的函數。Codeigniter表單驗證類
function showsupport()
{
$this->form_validation->set_rules('supportername','Name','trim|required|max_length[30]');
$this->form_validation->set_rules('supporteremail','Email Address','trim|required|valid_email');
$this->form_validation->set_rules('pledgedate','Pledge Date','trim|required');
$this->form_validation->set_rules('messagetxt','Your Message','trim|required|xss_clean');
if($this->form_validation->run() == FALSE)
{
$this->template->write_view('content','supportus');
$this->template->render();
} else {
$this->template->write('content','Your submission was a success');
$this->template->render();
}
}
<div id="supportform" class="formblock">
<?php
$formdata = array('id'=>'suppform');
echo form_open('homepage/showsupport',$formdata);
$namedata = array('name'=>'supportname','id'=>'supportname','size'=>'30','max_length'=>'25');
echo '<label for="supportername">Your Name:'.form_input($namedata,set_value('supportname')).'</label><br /><br />';
$emaildata = array('name'=>'supporteremail','id'=>'supporteremail','size'=>'30','max_lenth'=>'25');
echo '<label for="supporteremail">Email Address:'.form_input($emaildata,set_value('suppoteremail')).'</label><br /><br />';
$pledgedata = array('name'=>'pledgedate','id'=>'pledgedate','size'=>'30','max_length'=>'20');
echo '<label for="pledgedate">Today\'s Date:'.form_input($pledgedata,set_value('pledgedate')).'</label><br /><br />';
$msgdata = array('name'=>'messagetxt','id'=>'messagetxt','col'=>'2','rows'=>'8');
echo '<label for="messagetext">Your Pledge:'.form_textarea($msgdata).'</label><br />';
$submitdata = array('name'=>'submitbtn','id'=>'submitbtn','value'=>'Send');
echo '<label for="submitbutton">'.form_submit($submitdata).'</label><br />';
echo form_close();
?>
</div>
<div id="errorsechoed">
<div class="ui-widget">
<div class="ui-state-error ui-corner-all" style="padding: 0 .7em; border: none;">
<?php echo validation_errors('<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>');?>
這是它自己的形式。我必須在幾個小時內進行演示,而這種形式的工作是關鍵。感謝你們的幫助。
Ë
謝謝你,太多的咖啡!謝謝 – 2010-07-06 14:23:55