Welcome Guest, Not a member yet? Register   Sign In
302 moved temporarily
#1

Hi.

I have developed a web application and in local server works perfectly, but when I upload the application to a server on the internet (godaddy) I get this errors...

When I enter the data to enter the system in fractions of a second I get these errors and the page is reloaded

[Image: error1.jpg]

and when I repeat the same operation then I get this

[Image: error2.jpg]

This is my jquery
Code:
$(document).ready(function (){
$("#frm_login").submit(function (e){
   e.preventDefault();
   var url = $(this).attr('action');
   var method = $(this).attr('method');
    var data = $(this).serialize();
   $.ajax({
       url:url,
        type:method,
       data:data
   }).done(function(data){
       if(data !==''){window.location.href='Welcome/index';}else{alert('EL usuario y la contrasenna no coinciden');}
   });
});
});

This is my controller code (Welcome.php)
PHP Code:
<?php

if (!defined('BASEPATH'))
 
   exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

 public function 
new_user() {
 
       $username $this->input->post('username');
 
       $password sha1($this->input->post('password'));
 
       $check_user $this->Usuarios->login($username$password);
 
       if ($check_user == TRUE) {
 
           $data = array(
 
               'is_logued_in' => TRUE,
 
               'id_usuario' => $check_user->id,
 
               'perfil' => $check_user->perfil,
 
               'username' => $check_user->user,
 
               'password' => $check_user->pass,
 
               'nombre' => $check_user->name
            
);
 
           $this->session->set_userdata($data);
 
           $this->index();
 
       } else {
 
           
        
}
 
   }

 
   public function index() {

 
       echo $this->session->userdata('perfil');
 
       switch ($this->session->userdata('perfil')) {
 
           case '':
 
               $layout_data['footer'] = $this->load->view('Footer'NULLTRUE);
 
               $layout_data['token'] = $this->token();
 
               $this->load->view('Welcome_message'$layout_data);
 
               break;
 
           case 'Administrator':
 
               redirect(base_url() . 'Admin');
 
               break;
 
           case 'Operator':
 
               redirect(base_url() . 'Suscriptor');
 
               break;
 
           default:
 
               $layout_data['footer'] = $this->load->view('Footer'NULLTRUE);
 
               $this->load->view('Welcome_message'$layout_data);
 
               break;
 
       }
 
   }



I hope somebody can help me.
THX!!!!
Reply
#2

The link that you show (window.location.href='Welcome/index') is a relative link, leading to the misbehaving URL, Welcome/Welcome/index.
Try making it absolute ... window.location.href='/Welcome/index'
Reply
#3

(11-28-2018, 02:48 PM)ciadmin Wrote: The link that you show (window.location.href='Welcome/index') is a relative link, leading to the misbehaving URL, Welcome/Welcome/index.
Try making it absolute ... window.location.href='/Welcome/index'

Thanks for answering my question.

With your advice I solved error 404, error 302 is still in the controllers
Reply
#4

(This post was last modified: 11-29-2018, 02:15 PM by dave friend.)

302 is not an error. It indicates that the server was redirected to another URL. I see two redirect calls in your controller script that correspond to headers displayed in the first image in your post. My guess is that the first item in that screen grab is showing the new user form being submitted (posted).

Read about Server Status Codes
Reply




Theme © iAndrew 2016 - Forum software by © MyBB