I'm working on a signup page in CodeIgniter. The problem is, my post data doesn't come through. The following code always produces 'fail':
class Signup extends CI_Controller {
function index()
{
if ($this->input->post())
{
echo 'success';
}
else
{
echo 'fail';
echo form_open('signup');
echo form_input('username', 'Username');
echo form_input('email_address', 'Email address');
echo form_submit('submit', 'Create Acccount');
echo form_close();
}
}
}
What could be the problem?
To make matters even more interesting, on my localhost the form works just fine. It's when on the remote server when this fails.
Update 1: As requested, this is what the server outputs: (I obscured the url, I'm under non disclosure)
<form accept-charset="utf-8" method="post" action="http://www.url.com/signup">
<input type="text" value="Username" name="username">
<input type="text" value="Email address" name="email_address">
<input type="submit" value="Create Account" name="submit">
</form>
Update 2: I see another difference in behavior between the localhost and the remote server: When refreshing (cmd R or F5) the page after submitting the form, on the local host my browser asks me to send the form again. The same page on the remote server doesn't invoke that question from the browser so it looks like some redirecting or url problem is causing the problem?
Update 3: It appears that on the remote server, the user is being redirected by a 301. (moved permanently) I still have no idea where this redirect is coming from. The redirect effectively kills the post-data, so it explains why post() is returning false.
So, does anyone know why I'm being 301'd?
Update 4: I got redirected within CodeIgniter by setting my base_url as http://www.url.com in stead of http://url.com
After changing that, it solved the problem! :)