Home > Mobile >  Some error while submit form with empty field in PHP , Codeigniter
Some error while submit form with empty field in PHP , Codeigniter

Time:09-17

I am using Codeigniter framework.

My issue is:-

when I submit my booking form its shows me 503 service unavailable page if form fields are empty.

If all form fields have value then form is success fully submitting.

CodePudding user response:

You do this by varrious ways:-

(1) Form Validation

you need to set rules for input fields

$this->form_validation->set_rules('username', 'Username', 'required');
if ($this->form_validation->run() == FALSE)
  {
    //run your code on success here
  }
else
  {
    //run your code on failure here
  }

(2) By if else statement Condition.

 if ($_POST) {
        $data = array(
            'category' => $this->input->post('category'),
            'name' => $this->input->post('name'),
            'description' => $this->input->post('description'),
           );
        $this->model_name->method_name($data);
        redirect(base_url().'Controller/method/');
    } else {
     redirect(base_url().'Controller/method');
         }

CodePudding user response:

Here are some additional tips to help you troubleshoot what might be causing the 503 Service Unavailable to appear on the server-side of things:

  1. Reboot the Server
  2. Check for Unexpected Maintenance
  3. Server Connectivity Issues
  4. Improper Firewall Configuration
  5. Check the Logs
  6. Application Code or Script Bugs

For more information follow these websites .

  1. https://airbrake.io/blog/http-errors/503-service-unavailable
  2. https://askphpquestions.com/2020/11/30/getting-503-service-unavailable-on-codeigniter-in-apache-server/

I will send proper solution regarding form handling. If possible please share code snippet.

  • Related