Welcome Guest, Not a member yet? Register   Sign In
CI 2.1.0 form returns wrong url
#1

[eluser]Unknown[/eluser]
Hi all,

In a former version of CI I used a form and everything worked fine. Now I tried it again, but I got problems. What I did was exactly what has been described in the form validation tutorial. If I run the form:
Code:
http://myurl/index.php/form/
Firefox and Opera come back with the main page (at http://myurl/index.php) and url:
Code:
http://myurl/index.php?form

Below you find my code.

Controller form.php:
Code:
<?php

class Form extends CI_Controller {

function index()
{
  $this->load->helper(array('form','url'));

  $this->load->library('form_validation');

                if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('myform');
  }
  else
  {
   $this->load->view('formsuccess');
  }
}
}

?>
View myform.php:
Code:
<html>
<head>
<title>My Form</title>
</head>
<body>

<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>

<h5>Username</h5>
&lt;input type="text" name="username" value="" size="50" /&gt;

<h5>Password</h5>
&lt;input type="text" name="password" value="" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;input type="text" name="passconf" value="" size="50" /&gt;

<h5>Email Address</h5>
&lt;input type="text" name="email" value="" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
View formsuccess.php:
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h3>Your form was successfully submitted!</h3>

<p>&lt;?php echo anchor('form', 'Try it again!'); ?&gt;</p>

&lt;/body&gt;
&lt;/html&gt;

I use CI together with mySQL, Netbeans 7.0.1 and PHP 5.2.13 on Ubuntu.

Regards,

Carmen




Theme © iAndrew 2016 - Forum software by © MyBB