When uploading the project to infinityfree it does not work correctly, there are errors that the files do not exist, there are places where the same code works and in others it does not and in all the pages you see the CORB error, where supposed content of origin was blocked crossed (everything is loaded in the same domain). Disable the ajax to see if it worked with pure php at least and it skipped error 500. Change the code as much as I could in my understanding. Today I tried another host: 000webhost and everything works, but everything. Not a single error, maybe any due to my poorly optimized code, but everything works and it’s not slow.
What is this about? Should I enter code in .htaccess? I am a newbie, sorry if it is obvious what I propose but I want to learn.
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
Can you share some URLs on your site where a certain shared resource does and doesn’t work? If you know where the issue occurs, it would help a lot if you could just tell us instead of having us hunt for the errors ourselves on your site.
The CORS error is normal, because our 404 error page cannot be embedded into other pages. It’s not a CORS issue on your website. Once you fix the 404 errors, that error will disappear too.
What do you mean by this? Can you please provide steps on how we can reproduce this?
My best guess is that it’s a different path through your code which bypasses the bug that causes the page to crash.
Thanks for the clarification with CORS. It helps me a lot. About ajax, I mean that to check that the request itself was not the error hide the code, letting it work with pure php. When I did this I figured that the file I was looking for did not exist, so I deleted all the code from the php file and added an echo to check: it worked, the echo was displayed. Then I tried with die (json_encode ($ _ POST)) it worked. When I implement a query with try {} catch {} or without it, the error would appear again.
The worst thing is that the same php file works in other internal pages and actions.
Try entering this account:
admin0
123123
On the internal page of your profile in this case: https://feisbuk.rf.gd/perfil.php?usuario=TheGirl
You should be able to see your posts (SELECT), but this does not happen. But if you try to publish if you can do it (INSERT INTO). And the queries come from the same file. I am telling you this to illustrate why it works in one case and not in another. The url of the php file is https://feisbuk.rf.gd/funciones/modelo-publicacion.php
And I still don’t understand why it works on another host with the same code
As you say that file is not in that location … however all the code for sessions works correctly. If there is no session, it will return to login.php and that works.
<?php
function usuario_autentificado(){
if(!revisar_usuario()){
header("location:login.php");
exit();
}
}
function revisar_usuario(){
return isset($_SESSION["usuario"]);
}
session_start();
usuario_autentificado();
sesiones.php ↑↑↑
As I said, in another host the same code works without any problem
I dont understand that
I am saying that it is in another location in the same domain. It is the page that contains the entry form. It works I can use the accounts that I create.
OK, I spent too much time debugging this, and I think I understand what’s going on here.
This issue seems to be caused by a configuration flaw in our PHP setup to talk to MySQL. This results in data corruption if you read and write data both through phpMyAdmin. We would like to fix this but can’t do so without breaking many other sites, which leaves us in a bit of a bind.
To fix this, you need to manually set the MySQL connection charset in your database code. I see you’re using MySQLi, so you can use this function: PHP: mysqli::set_charset - Manual
You’ll probably want to set this to utf8mb4.
If you still get problems after that, please check the relevant records and tables in phpMyAdmin too. If you see any garbled characters there, you’ll need to fix those first.