Welcome Guest, Not a member yet? Register   Sign In
from post goes from index.php/form to index.php?form
#1

[eluser]coderex[/eluser]
Hi,

I've just starting learning CI and from the form example in codeigniter when I post, apart from no validation messages it goes from http://mysite.com/codigniter/index.php/form to http://mysite.com/codigniter/index.php?form which displays a completely different page, not the form, why is it showing ? ,?. I think there's some sort of config issue, can anyone give me a hand please?

## controller example in code igniter

<?php

class Form extends CI_Controller {

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

$this->load->library('Form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');

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

<html>
<head>
<title>My Form</title>
</head>
<body>

## myform

<?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;

## form success

&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;
#2

[eluser]InsiteFX[/eluser]
Code:
&lt;?php echo form_open('controller/method');?&gt;

&lt;?php echo form_open('controller/form');?&gt;

InsiteFX
#3

[eluser]coderex[/eluser]
Hi, no still produces a ? e.g if you look at the source code of what form_help.php is producing it's showing http://127.0.0.1/codeigniter/index.php?form/ if I add your suggestion it just shows http://127.0.0.1/codeigniter/index.php?controller/form/

if I do a hardcoded test of and name it something else, it works, so what's the "?" doing there, I don't see how it's placed in form_help.php

//## hard coded example below works

&lt;form action="http://127.0.0.1/codeigniter/index.php/form/" method="post" accept-charset="utf-8"&gt;

<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;
#4

[eluser]danmontgomery[/eluser]
form_open() uses base_url. If a ? is showing up, it's in base_url, which is in config/config.php
#5

[eluser]coderex[/eluser]
Actually needed to set 'enable_query_strings' from 'TRUE' to 'FALSE' which true by default, unless I changed it previously, can't remember, but solved now, you got me looking in the area anyway Wink

set

$config['enable_query_strings'] = FALSE;




Theme © iAndrew 2016 - Forum software by © MyBB