Welcome Guest, Not a member yet? Register   Sign In
Form Validation Problem!
#1

[eluser]octavianmh[/eluser]
Guys-

So.. I'm building a widget of sorts that takes some input from a URL (which is not included in the validation), validates a field, and then ideally does some processing and shows success if, ya know, successful. But I fear I'm doing something dumb with the form stuff, as I never get to the "process" part of the equation.

Here's a snip from my controller:
Code:
<?php

class Form extends Controller
{
    function _remap($serviceKey)
    {
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
        $this->form_validation->set_rules('mobileNumber', 'Mobile number', 'required|min_length[10]|max_length[11]|trim|xss_clean');
                
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('standalone');
        }
        else
        {
            echo "Validation Success";

        }
    }
}
?>

And my form view:
Code:
<html>
<head>
<title>Subscribe Here</title>
</head>
<body>
<h3>You've Reached the Standalone Subscribe Widget display!</h3>
    &lt;?php echo validation_errors(); ?&gt;
    &lt;?php echo form_open('form'); ?&gt;
    &lt;input id="mobileNumber" type="text" value=""&gt;&lt;/input>
    &lt;input type="submit"/&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

And the link I'd like to use to REACH said form is:

http://www.blah.com/index.php/form/8difj...52FjcKu98e

Where the long string is a hash I need to process how the form should act if validation is successful.

Anyway, everytime I "submit" it just dumps me back to the form itself, I never see my "validation success" echo!

Boooo!

Any ideas?
#2

[eluser]bobbob[/eluser]
I think this:
&lt;input id="mobileNumber" type="text" value=""&gt;&lt;/input>

should be
&lt;input name="mobileNumber" id="mobileNumber" type="text" value=""&gt;&lt;/input>
#3

[eluser]richardporteous[/eluser]
your code looks good! except your I believe echo is being 'overwritten'

to test this replace your echo with
redirect('somecontroller');
or redirect to another function...




Theme © iAndrew 2016 - Forum software by © MyBB