0

On my website I have a registering form for new users to sing up.
When I register an account, or when my friends try it, the process succeeds and the data is inserted in the database.

The problem is that when other people, from all over the world, register an account most of the time this happens:
1) The process succeeds, with no errors that are thrown.
but
2) No data is inserted into the database.

The database connection is created with:

// Connecting to the database
$database = new mysqli($DatabaseServer, $DatabaseUser, $DatabasePass, $DatabaseName);

In the registering process the data is inserted with:

$stmt = $database->prepare("INSERT INTO `users` (`username`, `password`, `email`, `email_activation_code`, `name`, `active`, `ip`, `date`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");

$stmt->bind_param('ssssssss', $_POST['username'], $password, $_POST['email'], $email_code, $_POST['name'], $active, $_SERVER['REMOTE_ADDR'], $date);
$result = $stmt->execute();
$stmt->close();

So far I've tried:
- register from multiple locations with a vpn, and from different physical locations, all successful.
-I've made logs of the data that is used when registering when it fails (with permissions of the user).
Nothing weird is to be seen, and when I use his data I can register an account perfectly.
When doing this we both tried it around the same time, while I had the database open, so I'm sure the database is running at that moment (or an error should have been throw because of the missing connection anyway).
-I've tried to made a log of the $stmt->error_list which results into nothing (because no errors are thrown).
-Normal error catching with a 'try catch' also results into nothing, because, again, no errors are thrown.

I noticed the problem after updating the database to mariadb 10.3.20. It is now on version 10.3.22.

I'm at the point that I have no idea where to look anymore since only a part of the registering process fail.
Any direction to look into is appreciated.

Memonon
  • 11
  • 1
  • 5
  • check this: https://stackoverflow.com/questions/47505254/php-no-error-but-data-not-inserting-into-database – Farzad Rastgar Sani Feb 08 '20 at 10:29
  • So you have logs of data which fails to be inserted, but you can't replicate the issue with the same data used? – Paul Spiegel Feb 08 '20 at 11:17
  • @PaulSpiegel correct. When the user uses his data it fails. When I use the same data it succeeds. – Memonon Feb 08 '20 at 11:23
  • @FarzadRastgarSani I already came across that topic. The files are correct and no errors are thrown or listed from the connections. In that topic data inserting fails all of the times. Here it does not. – Memonon Feb 08 '20 at 11:26
  • Your server will thrown an auto error into error log_file if you enabled in php.ini file, (Enabled as default on most servers) you can check in Cpanel or in error log_file, Sure you dont see any error in error log file ? – Dlk Feb 08 '20 at 12:05
  • first lets display errors https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display and if th at doesn't help, lts see if thebexecute has an erro with print_r($stmt->errorInfo()); – nbk Feb 08 '20 at 12:23
  • @Dlk The error log_file does not give an error around the registering process. – Memonon Feb 08 '20 at 12:37
  • But did you configure PHP to store errors in the log? – Your Common Sense Feb 08 '20 at 12:48
  • @nbk I've displayed the errors, and I've tried to print and log the stmt errors. But there are none. When I log the insert result it should send nothing or an error on fail. Even when the insert does nothing it logs a result if it was successful. – Memonon Feb 08 '20 at 12:49
  • @YourCommonSense yes. – Memonon Feb 08 '20 at 12:49
  • I would show all codes in question step by step to regisration and db connection, it might be a bug in mariadb. – Dlk Feb 08 '20 at 12:53
  • You need to show us more of your code as well as table schema. – Dharman Feb 08 '20 at 13:50
  • ok you have no php errors and you don't have any mysql errors. Check also the mysql logs if there is any kind of error. – nbk Feb 08 '20 at 16:48

1 Answers1

0

We went trough all of it again, the code and database with the few logged users that failed and succeeded the register process.

The problem was not with the code but in the database itself. The previous maintainer set the column that stored the ip to varchar(32) which is enhough for an Ipv4 address but not for a an IPv6 address. We have changed the column to a varchar(64) so the address fits again. This seems to fix the problem... unless there is something else but I wont know that until new users attempt to register again.

It is still weird that the error was not logged in any of the logs. With the comments given under the comments I will try to workout why it was not logged and it pretended everything was fine and with that I will make sure any new errors will be logged.
Thanks for the help.

Memonon
  • 11
  • 1
  • 5