Codeignitor Form Validation Error: Unable to access the page to fill a form after using form validation












0















I have created an Add User form in codeignitor which has the link http://example.com/users/add. And in the controller I have the following code for form validation:



$this->form_validation->set_rules('firstName', 'First Name', 'required');
$this->form_validation->set_rules('lastName', 'Last Name', '');
$this->form_validation->set_rules('guardian1', 'Guardian First', 'required');
$this->form_validation->set_rules('guardian2', 'Guardian Second', '');
$this->form_validation->set_rules('mobile', 'Mobile Number', 'required');
$this->form_validation->set_rules('phone', 'Phone Number', '');
$this->form_validation->set_rules('dob', 'Date Of Birth', 'required');
$this->form_validation->set_rules('status', 'Account Status', 'required');
$this->form_validation->set_rules('confirmation', 'Confirm Creation', 'required');

if ($this->form_validation->run == FALSE)
{
redirect('news');
}
else
{
redirect('users/view');
}


When I try to access the url to add user, it directly redirects me to http://example.com/news without opening the form page where I can fill the form.
This is my form code for Add User form:



<form id="form-project" role="form" method="post" action="<?php echo base_url(); ?>users/add" autocomplete="off" novalidate>
<div class="form-group-attached">
<div class="row clearfix">
<div class="col-md-6">
<div class="form-group form-group-default required">
<label>First name</label>
<input type="text" class="form-control" name="firstName" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group form-group-default">
<label>Last name</label>
<input type="text" class="form-control" name="lastName">
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-md-6">
<div class="form-group form-group-default required">
<label>Parent I / Guardian</label>
<input type="text" class="form-control" name="guardian1" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group form-group-default">
<label>Parent II / Guardian</label>
<input type="text" class="form-control" name="guardian2">
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-md-6">
<div class="form-group form-group-default required">
<label>Mobile</label>
<input type="text" class="form-control" name="mobile" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group form-group-default">
<label>Phone</label>
<input type="text" class="form-control" name="phone">
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-md-6">
<div class="form-group form-group-default input-group required">
<div class="form-input-group">
<label>Date Of Birth</label>
<input id="start-date" type="text" class="form-control date" name="dob" required>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group form-group-default input-group">
<div class="form-input-group">
<label class="inline">Account Status</label>
</div>
<div class="input-group-addon bg-transparent h-c-50">
<input type="checkbox" name="status" data-init-plugin="switchery" data-size="small" data-color="primary" checked="checked" required />
</div>
</div>
</div>
</div>
</div>
<br>
<div class="pull-left">
<div class="checkbox check-primary">
<input type="checkbox" checked="unchecked" value="1" id="checkbox-agree" name="confirmation">
<label for="checkbox-agree">I hereby certify that the information above is true and accurate
</label>
</div>
</div>
<br>
<button class="btn btn-primary" type="submit">Submit</button>
<button class="btn btn-default" type="reset"><i class="pg-close"></i>Clear</button>
</form>


P.s I have the form validation library and url helper loaded.










share|improve this question



























    0















    I have created an Add User form in codeignitor which has the link http://example.com/users/add. And in the controller I have the following code for form validation:



    $this->form_validation->set_rules('firstName', 'First Name', 'required');
    $this->form_validation->set_rules('lastName', 'Last Name', '');
    $this->form_validation->set_rules('guardian1', 'Guardian First', 'required');
    $this->form_validation->set_rules('guardian2', 'Guardian Second', '');
    $this->form_validation->set_rules('mobile', 'Mobile Number', 'required');
    $this->form_validation->set_rules('phone', 'Phone Number', '');
    $this->form_validation->set_rules('dob', 'Date Of Birth', 'required');
    $this->form_validation->set_rules('status', 'Account Status', 'required');
    $this->form_validation->set_rules('confirmation', 'Confirm Creation', 'required');

    if ($this->form_validation->run == FALSE)
    {
    redirect('news');
    }
    else
    {
    redirect('users/view');
    }


    When I try to access the url to add user, it directly redirects me to http://example.com/news without opening the form page where I can fill the form.
    This is my form code for Add User form:



    <form id="form-project" role="form" method="post" action="<?php echo base_url(); ?>users/add" autocomplete="off" novalidate>
    <div class="form-group-attached">
    <div class="row clearfix">
    <div class="col-md-6">
    <div class="form-group form-group-default required">
    <label>First name</label>
    <input type="text" class="form-control" name="firstName" required>
    </div>
    </div>
    <div class="col-md-6">
    <div class="form-group form-group-default">
    <label>Last name</label>
    <input type="text" class="form-control" name="lastName">
    </div>
    </div>
    </div>
    <div class="row clearfix">
    <div class="col-md-6">
    <div class="form-group form-group-default required">
    <label>Parent I / Guardian</label>
    <input type="text" class="form-control" name="guardian1" required>
    </div>
    </div>
    <div class="col-md-6">
    <div class="form-group form-group-default">
    <label>Parent II / Guardian</label>
    <input type="text" class="form-control" name="guardian2">
    </div>
    </div>
    </div>
    <div class="row clearfix">
    <div class="col-md-6">
    <div class="form-group form-group-default required">
    <label>Mobile</label>
    <input type="text" class="form-control" name="mobile" required>
    </div>
    </div>
    <div class="col-md-6">
    <div class="form-group form-group-default">
    <label>Phone</label>
    <input type="text" class="form-control" name="phone">
    </div>
    </div>
    </div>
    <div class="row clearfix">
    <div class="col-md-6">
    <div class="form-group form-group-default input-group required">
    <div class="form-input-group">
    <label>Date Of Birth</label>
    <input id="start-date" type="text" class="form-control date" name="dob" required>
    </div>
    </div>
    </div>
    <div class="col-md-6">
    <div class="form-group form-group-default input-group">
    <div class="form-input-group">
    <label class="inline">Account Status</label>
    </div>
    <div class="input-group-addon bg-transparent h-c-50">
    <input type="checkbox" name="status" data-init-plugin="switchery" data-size="small" data-color="primary" checked="checked" required />
    </div>
    </div>
    </div>
    </div>
    </div>
    <br>
    <div class="pull-left">
    <div class="checkbox check-primary">
    <input type="checkbox" checked="unchecked" value="1" id="checkbox-agree" name="confirmation">
    <label for="checkbox-agree">I hereby certify that the information above is true and accurate
    </label>
    </div>
    </div>
    <br>
    <button class="btn btn-primary" type="submit">Submit</button>
    <button class="btn btn-default" type="reset"><i class="pg-close"></i>Clear</button>
    </form>


    P.s I have the form validation library and url helper loaded.










    share|improve this question

























      0












      0








      0








      I have created an Add User form in codeignitor which has the link http://example.com/users/add. And in the controller I have the following code for form validation:



      $this->form_validation->set_rules('firstName', 'First Name', 'required');
      $this->form_validation->set_rules('lastName', 'Last Name', '');
      $this->form_validation->set_rules('guardian1', 'Guardian First', 'required');
      $this->form_validation->set_rules('guardian2', 'Guardian Second', '');
      $this->form_validation->set_rules('mobile', 'Mobile Number', 'required');
      $this->form_validation->set_rules('phone', 'Phone Number', '');
      $this->form_validation->set_rules('dob', 'Date Of Birth', 'required');
      $this->form_validation->set_rules('status', 'Account Status', 'required');
      $this->form_validation->set_rules('confirmation', 'Confirm Creation', 'required');

      if ($this->form_validation->run == FALSE)
      {
      redirect('news');
      }
      else
      {
      redirect('users/view');
      }


      When I try to access the url to add user, it directly redirects me to http://example.com/news without opening the form page where I can fill the form.
      This is my form code for Add User form:



      <form id="form-project" role="form" method="post" action="<?php echo base_url(); ?>users/add" autocomplete="off" novalidate>
      <div class="form-group-attached">
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default required">
      <label>First name</label>
      <input type="text" class="form-control" name="firstName" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default">
      <label>Last name</label>
      <input type="text" class="form-control" name="lastName">
      </div>
      </div>
      </div>
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default required">
      <label>Parent I / Guardian</label>
      <input type="text" class="form-control" name="guardian1" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default">
      <label>Parent II / Guardian</label>
      <input type="text" class="form-control" name="guardian2">
      </div>
      </div>
      </div>
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default required">
      <label>Mobile</label>
      <input type="text" class="form-control" name="mobile" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default">
      <label>Phone</label>
      <input type="text" class="form-control" name="phone">
      </div>
      </div>
      </div>
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default input-group required">
      <div class="form-input-group">
      <label>Date Of Birth</label>
      <input id="start-date" type="text" class="form-control date" name="dob" required>
      </div>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default input-group">
      <div class="form-input-group">
      <label class="inline">Account Status</label>
      </div>
      <div class="input-group-addon bg-transparent h-c-50">
      <input type="checkbox" name="status" data-init-plugin="switchery" data-size="small" data-color="primary" checked="checked" required />
      </div>
      </div>
      </div>
      </div>
      </div>
      <br>
      <div class="pull-left">
      <div class="checkbox check-primary">
      <input type="checkbox" checked="unchecked" value="1" id="checkbox-agree" name="confirmation">
      <label for="checkbox-agree">I hereby certify that the information above is true and accurate
      </label>
      </div>
      </div>
      <br>
      <button class="btn btn-primary" type="submit">Submit</button>
      <button class="btn btn-default" type="reset"><i class="pg-close"></i>Clear</button>
      </form>


      P.s I have the form validation library and url helper loaded.










      share|improve this question














      I have created an Add User form in codeignitor which has the link http://example.com/users/add. And in the controller I have the following code for form validation:



      $this->form_validation->set_rules('firstName', 'First Name', 'required');
      $this->form_validation->set_rules('lastName', 'Last Name', '');
      $this->form_validation->set_rules('guardian1', 'Guardian First', 'required');
      $this->form_validation->set_rules('guardian2', 'Guardian Second', '');
      $this->form_validation->set_rules('mobile', 'Mobile Number', 'required');
      $this->form_validation->set_rules('phone', 'Phone Number', '');
      $this->form_validation->set_rules('dob', 'Date Of Birth', 'required');
      $this->form_validation->set_rules('status', 'Account Status', 'required');
      $this->form_validation->set_rules('confirmation', 'Confirm Creation', 'required');

      if ($this->form_validation->run == FALSE)
      {
      redirect('news');
      }
      else
      {
      redirect('users/view');
      }


      When I try to access the url to add user, it directly redirects me to http://example.com/news without opening the form page where I can fill the form.
      This is my form code for Add User form:



      <form id="form-project" role="form" method="post" action="<?php echo base_url(); ?>users/add" autocomplete="off" novalidate>
      <div class="form-group-attached">
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default required">
      <label>First name</label>
      <input type="text" class="form-control" name="firstName" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default">
      <label>Last name</label>
      <input type="text" class="form-control" name="lastName">
      </div>
      </div>
      </div>
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default required">
      <label>Parent I / Guardian</label>
      <input type="text" class="form-control" name="guardian1" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default">
      <label>Parent II / Guardian</label>
      <input type="text" class="form-control" name="guardian2">
      </div>
      </div>
      </div>
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default required">
      <label>Mobile</label>
      <input type="text" class="form-control" name="mobile" required>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default">
      <label>Phone</label>
      <input type="text" class="form-control" name="phone">
      </div>
      </div>
      </div>
      <div class="row clearfix">
      <div class="col-md-6">
      <div class="form-group form-group-default input-group required">
      <div class="form-input-group">
      <label>Date Of Birth</label>
      <input id="start-date" type="text" class="form-control date" name="dob" required>
      </div>
      </div>
      </div>
      <div class="col-md-6">
      <div class="form-group form-group-default input-group">
      <div class="form-input-group">
      <label class="inline">Account Status</label>
      </div>
      <div class="input-group-addon bg-transparent h-c-50">
      <input type="checkbox" name="status" data-init-plugin="switchery" data-size="small" data-color="primary" checked="checked" required />
      </div>
      </div>
      </div>
      </div>
      </div>
      <br>
      <div class="pull-left">
      <div class="checkbox check-primary">
      <input type="checkbox" checked="unchecked" value="1" id="checkbox-agree" name="confirmation">
      <label for="checkbox-agree">I hereby certify that the information above is true and accurate
      </label>
      </div>
      </div>
      <br>
      <button class="btn btn-primary" type="submit">Submit</button>
      <button class="btn btn-default" type="reset"><i class="pg-close"></i>Clear</button>
      </form>


      P.s I have the form validation library and url helper loaded.







      php frameworks






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 5:13









      Tauseef ShahTauseef Shah

      409




      409
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You need to change you if condition:



          if ($this->form_validation->run == FALSE)


          to



          if ($this->form_validation->run != FALSE)


          Then, If validation is failed, user will be redirect back to "users/view" and redirect to "news" if passed.






          share|improve this answer
























          • I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

            – Tauseef Shah
            Nov 15 '18 at 7:02











          • If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

            – Van Tho
            Nov 15 '18 at 7:14











          • Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

            – Tauseef Shah
            Nov 15 '18 at 7:40











          • How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

            – Van Tho
            Nov 15 '18 at 7:54













          • I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

            – Tauseef Shah
            Nov 15 '18 at 8:20



















          0














          If you want to redirect back to your form then, your redirection statement should be in if block body like this



          if($this->form_validation->run == FALSE)
          {
          redirect('users/view');
          }
          else
          {
          redirect('news');
          }





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312846%2fcodeignitor-form-validation-error-unable-to-access-the-page-to-fill-a-form-afte%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You need to change you if condition:



            if ($this->form_validation->run == FALSE)


            to



            if ($this->form_validation->run != FALSE)


            Then, If validation is failed, user will be redirect back to "users/view" and redirect to "news" if passed.






            share|improve this answer
























            • I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

              – Tauseef Shah
              Nov 15 '18 at 7:02











            • If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

              – Van Tho
              Nov 15 '18 at 7:14











            • Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

              – Tauseef Shah
              Nov 15 '18 at 7:40











            • How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

              – Van Tho
              Nov 15 '18 at 7:54













            • I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

              – Tauseef Shah
              Nov 15 '18 at 8:20
















            0














            You need to change you if condition:



            if ($this->form_validation->run == FALSE)


            to



            if ($this->form_validation->run != FALSE)


            Then, If validation is failed, user will be redirect back to "users/view" and redirect to "news" if passed.






            share|improve this answer
























            • I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

              – Tauseef Shah
              Nov 15 '18 at 7:02











            • If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

              – Van Tho
              Nov 15 '18 at 7:14











            • Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

              – Tauseef Shah
              Nov 15 '18 at 7:40











            • How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

              – Van Tho
              Nov 15 '18 at 7:54













            • I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

              – Tauseef Shah
              Nov 15 '18 at 8:20














            0












            0








            0







            You need to change you if condition:



            if ($this->form_validation->run == FALSE)


            to



            if ($this->form_validation->run != FALSE)


            Then, If validation is failed, user will be redirect back to "users/view" and redirect to "news" if passed.






            share|improve this answer













            You need to change you if condition:



            if ($this->form_validation->run == FALSE)


            to



            if ($this->form_validation->run != FALSE)


            Then, If validation is failed, user will be redirect back to "users/view" and redirect to "news" if passed.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 15 '18 at 6:26









            Van ThoVan Tho

            846




            846













            • I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

              – Tauseef Shah
              Nov 15 '18 at 7:02











            • If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

              – Van Tho
              Nov 15 '18 at 7:14











            • Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

              – Tauseef Shah
              Nov 15 '18 at 7:40











            • How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

              – Van Tho
              Nov 15 '18 at 7:54













            • I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

              – Tauseef Shah
              Nov 15 '18 at 8:20



















            • I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

              – Tauseef Shah
              Nov 15 '18 at 7:02











            • If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

              – Van Tho
              Nov 15 '18 at 7:14











            • Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

              – Tauseef Shah
              Nov 15 '18 at 7:40











            • How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

              – Van Tho
              Nov 15 '18 at 7:54













            • I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

              – Tauseef Shah
              Nov 15 '18 at 8:20

















            I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

            – Tauseef Shah
            Nov 15 '18 at 7:02





            I want it to load "users/add" first where I can enter that data in the form before redirecting. It is redirecting automatically to "news" whenever I try to access "users/add" without letting me insert data in the form.

            – Tauseef Shah
            Nov 15 '18 at 7:02













            If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

            – Van Tho
            Nov 15 '18 at 7:14





            If so, you need two functions, not just one. First function will only show the form, and the second function will handle the data from html form (you need to put your validator in the second function).

            – Van Tho
            Nov 15 '18 at 7:14













            Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

            – Tauseef Shah
            Nov 15 '18 at 7:40





            Thanks!! It worked but is there any way to use a single function for this? (I have seen some applications use single function for handling this)

            – Tauseef Shah
            Nov 15 '18 at 7:40













            How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

            – Van Tho
            Nov 15 '18 at 7:54







            How about checking request method? check this link. If validation is FALSE or requested method is GET, show the form. If validation is FALSE and method is POST, redirect to news

            – Van Tho
            Nov 15 '18 at 7:54















            I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

            – Tauseef Shah
            Nov 15 '18 at 8:20





            I switched to using post request method and now I can use form_validation along with route in a single function. Thanks!!!

            – Tauseef Shah
            Nov 15 '18 at 8:20













            0














            If you want to redirect back to your form then, your redirection statement should be in if block body like this



            if($this->form_validation->run == FALSE)
            {
            redirect('users/view');
            }
            else
            {
            redirect('news');
            }





            share|improve this answer




























              0














              If you want to redirect back to your form then, your redirection statement should be in if block body like this



              if($this->form_validation->run == FALSE)
              {
              redirect('users/view');
              }
              else
              {
              redirect('news');
              }





              share|improve this answer


























                0












                0








                0







                If you want to redirect back to your form then, your redirection statement should be in if block body like this



                if($this->form_validation->run == FALSE)
                {
                redirect('users/view');
                }
                else
                {
                redirect('news');
                }





                share|improve this answer













                If you want to redirect back to your form then, your redirection statement should be in if block body like this



                if($this->form_validation->run == FALSE)
                {
                redirect('users/view');
                }
                else
                {
                redirect('news');
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 7:24









                Zeeshan TanveerZeeshan Tanveer

                313




                313






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312846%2fcodeignitor-form-validation-error-unable-to-access-the-page-to-fill-a-form-afte%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python