Welcome Guest, Not a member yet? Register   Sign In
Function form_open error
#1

[eluser]Unknown[/eluser]
Hi.

I have a form and in localhost it works fine but when i put it in my linux server gives me this error in formulario_view.php. I work with PHP5 in both locations:


Fatal error: Call to undefined function form_open() in /home/klaudio/public_html/ci/system/application/views/formulario_view.php on line 18

The code:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
2 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 &lt;html&gt;
4 &lt;head&gt;
5 &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
6 &lt;title&gt;Godbit Code Igniter Tutorial: Creating a simple Registration Form&lt;/title&gt;
7 &lt;style type="text/css"&gt;
8 body {
9 font: small/1.5em Verdana, Arial, Helvetica, serif;
10 }
11 &lt;/style&gt;
12 &lt;/head&gt;
13 &lt;body&gt;
14 <h1>Formulário de Registo</h1>
15 <p>Por favor complete o seguinte formulário:</p>
17 &lt;?php echo $this->validation->error_string; ?&gt;
18 &lt;?php echo form_open('formulario/index'); ?&gt;
19 <p><label for="nome">Nome: </label><br />&lt;?php echo form_input($nome); ?&gt;</p>
20 <p><label for="email">E-mail: </label><br />&lt;?php echo form_input($email); ?&gt;</p>
21 <p>Por favor indique um ou mais clubes que mais goste</p>
22 <p>&lt;?php echo form_checkbox($purpose); ?&gt; <label for="purpose">Benfica</label></p>
23 <p>&lt;?php echo form_checkbox($prepare); ?&gt; <label for="prepare">Sporting</label></p>
24 <p>&lt;?php echo form_checkbox($principles); ?&gt; <label for="principles">Porto</label></p>
25 <p>&lt;?php echo form_checkbox($power); ?&gt; <label for="power">Barcelona</label></p>
26 <p><label for="comentarios">Comentários: </label><br />&lt;?php echo form_textarea
27 ($comentarios); ?&gt;</p>
28 &lt;?php echo form_submit('submit', 'Submit'); ?&gt;
29 &lt;?php echo form_close(); ?&gt;
30 &lt;/body&gt;
31 &lt;/html&gt;

The formulario.php controller file

&lt;?php
class Formulario extends Controller {

function index()
{
# Validations
$this->load->library('validation');
$this->load->library('email');

$rules['nome'] = "required";
$rules['email'] = "required|valid_email";

$this->validation->set_rules($rules);


# Input and textarea field attributes
$data["nome"] = array('name' => 'nome', 'id' => 'nome');
$data['email'] = array('name' => 'email', 'id' => 'email');
$data['comentarios'] = array('name' => 'comentarios', 'id' => 'comentarios', 'rows' => 3, 'cols' => 40);

# Checkbox attributes
$data['purpose'] = array('name' => 'seminario[]', 'id' => 'purpose', 'value' => 'Purpose of Prayer', 'checked' => FALSE);
$data['prepare'] = array('name' => 'seminario[]', 'id' => 'prepare', 'value' => 'Prepare for Prayer', 'checked' => FALSE);
$data['principles'] = array('name' => 'seminario[]', 'id' => 'principles', 'value' => 'Principles of Prayer', 'checked' => FALSE);
$data['power'] = array('name' => 'seminario[]', 'id' => 'power', 'value' => 'Power in Prayer', 'checked' => FALSE);


if ($this->validation->run() == FALSE)
{
$this->load->view('formulario_view', $data);
}
else
{
$nome = $this->input->post('nome');
$email = $this->input->post('email');
$comentarios = $this->input->post('comentarios');
$seminarios = "";

foreach($this->input->post('seminario') as $value){
$seminarios .= "$value\n";
}

$message = "$nome ($email) would like to register for the following seminarios:\n$seminarios and had this to say:\n\n$comentarios";
$this->email->from($email, $nome);
$this->email->to('[email protected]');

$this->email->subject('Registo Seminário');
$this->email->message($message);

$this->email->send();

$this->load->view('formulariosucesso');
}
}
#2

[eluser]座頭市[/eluser]
You didn't load the forms helper.
#3

[eluser]Unknown[/eluser]
yes i did not loaded form loader. Thanks Smile




Theme © iAndrew 2016 - Forum software by © MyBB