Welcome Guest, Not a member yet? Register   Sign In
how to submit a form from view to specific method of specific controller
#1

[eluser]manishchndk[/eluser]
Dear friends, i am not able to submit a form to a particular controller in codeigniter 2.0 but the same is working good with codeigniter 1.7 version. I have written the code below, if any one of you know this help me.

Note: Car is the project Name
My default controller is set to welcome.php
In config.php i defined a variable as
$config['base_url'] = 'http://localhost/car/';


The code which i have written in view : welcome_view.php

<body>
<form name="admin_login" id="id_login" action="<?php echo base_url(); ?>user/login" method="POST" >
User Name <input type="text" name="login_name" id="login_name" />
Password <input type="password" name="login_password" id="login_password" />
<input type="submit" name="register" id="register" value="Register" />
</form>
</body>

I want to submit the form details to a controller name "user.php" having method login but it is showing me an error message that:

"The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error."

but the same code is working fine in codeigniter 1.7 version i don't know what to do.
can anyone help me in that.
#2

[eluser]InsiteFX[/eluser]
Try changing the URL Protocol!
Code:
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'            Default - auto detects
| 'PATH_INFO'        Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'        Uses the REQUEST_URI
| 'ORIG_PATH_INFO'    Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol']    = 'REQUEST_URI';

InsiteFX
#3

[eluser]manishchndk[/eluser]
i tried the way u told me but still getting the same error message any other solution do u know even i am not able redirect to other methods of default controller, it is executing only index function of default controller.
#4

[eluser]Cristian Gilè[/eluser]
Probably index.php is missing in the form action.

The right version:

Code:
<form name="admin_login" id="id_login" action="<?php echo base_url(); ?>index.php/user/login" method="POST" >

You can also use the site_url(). index.php will be added to the URL automatically.

Code:
<form name="admin_login" id="id_login" action="<?php echo site_url('user/login'); ?>" method="POST" >


Cristian Gilè




Theme © iAndrew 2016 - Forum software by © MyBB