1

I have a website, with some pages like any other website. It works perfectly on my computer(localhost).

But when I uploaded it to a real server, some problems appeared in login pages..

The problem's after I insert my login information and click submit IT DOESN'T redirect me to main page.. It keeps spinning!

$(document).ready(function() {
  end_loader();

  $('#ulogin-form').submit(function(e) {
    e.preventDefault()
    var _this = $(this)
    var el = $('<div>')
    el.addClass('alert alert-danger err_msg')
    el.hide()
    $('.err_msg').remove()
    if ($('#password').val() != $('#cpassword').val()) {
      el.text('Password does not match')
      _this.prepend(el)
      el.show('slow')
      $('html, body').scrollTop(0)
      return false;
    }
    if (_this[0].checkValidity() == false) {
      _this[0].reportValidity();
      return false;
    }
    start_loader()
    $.ajax({
      url: _base_url_ + "classes/Login.php?f=login_user",
      method: 'POST',
      type: 'POST',
      data: new FormData($(this)[0]),
      dataType: 'json',
      cache: false,
      processData: false,
      contentType: false,
      error: err => {
        console.log(err)
        alert('An error occurred')
        end_loader()
      },
      success: function(resp) {
        if (resp.status == 'success') {
          location.href = ('./')
        } else if (!!resp.msg) {
          el.html(resp.msg)
          el.show('slow')
          _this.prepend(el)
          $('html, body').scrollTop(0)
        } else {
          alert('An error occurred')
          console.log(resp)
        }
        end_loader()
      }
    })
  })
})

Sanket Shah
  • 2,888
  • 1
  • 11
  • 22
  • In success: `console.log(resp)`. Also check the browser console for errors. –  Aug 14 '22 at 15:59
  • What's your server environment? How are you running your scripts on both servers? Do they differ? – Progrock Aug 14 '22 at 16:01
  • Is this a cross domain issue? Is your base url defined? – Progrock Aug 14 '22 at 16:05
  • @Progrock the server host is from this website "awardspace.com" – AhSaN HoOmI Aug 14 '22 at 16:06
  • @Progrock yes it is domain from web site hosting..and yes the base_url is defined – AhSaN HoOmI Aug 14 '22 at 16:09
  • You need to do some debugging using your browser's Developer Tools and look for console errors or other problems with ajax requests etc. – ADyson Aug 14 '22 at 16:09
  • Press F12 in the browser to open the dev tools. Switch to the console tab and turn on the xhr filter. Then submit the form and check the xhr. –  Aug 14 '22 at 16:17
  • @ChrisG I did as you told me.. and i got this result: "undefined mysqli_stmt::$get->result in class/login.php line50" how to fixing that? – AhSaN HoOmI Aug 14 '22 at 21:28
  • So, did you see the xhr? Check its response? –  Aug 14 '22 at 21:30
  • This is the website link ..i hope you to check out this problem...http://allam.mywebcommunity.org – AhSaN HoOmI Aug 14 '22 at 21:36
  • More than 5 days trying to solve this problem..but i can't – AhSaN HoOmI Aug 14 '22 at 21:38
  • So, now you got that error message, did you start by googling it? It would lead you to here, which should explain the problem and outline the solution: https://stackoverflow.com/questions/8321096/call-to-undefined-method-mysqli-stmtget-result – ADyson Aug 15 '22 at 04:43

1 Answers1

0

As you have stated that the code and everything else works offline and the responses made by the other programmers, I will continue on that for now by asuming it works offline as you have said.

It might be the case that your local enviroment is more up to date then your online server enviroment. As local you could have PHP 8 but online run 7.0

Example: PHP 7.2 added 'PASSWORD_ARGON2ID' and if you have used that then online enviroment PHP 7.1 will never work since it doesn't know what to do.

Please confirm by: Create a file that contains the following code:

<?php
 phpinfo();
?>

and confirm that your online server is atleast equal to your offline version. Further versions might rollback certain functions so try to have the exact same PHP and ?Linux or Apache? version as offline.

After you confirm that the offline and online versions are the same, let's then try the other issue such as "undefined mysqli_stmt::$get->result in class/login.php line50", it would help if you would provide code.

Also, if you upload your work (code) directly to git->to online server, make sure your .gitignore doesn't ignore the files that you need.

Let's hope this helps.

AndradeL
  • 64
  • 7