Page 1 of 1

Curious PHP issue

Posted: Fri Sep 18, 2020 2:09 pm
by obrienj
I have the following PHP snippet generated by one the the extensions:

Code: Select all

<?php
session_start();

$success_page = 'https://<a valid URL>';
$error_page = './page1.html';
$mysql_server = 'localhost';
$mysql_username = 'xxxxxxxxx';
$mysql_password = 'xxxxxxxx';
$mysql_database = 'xxxxxxxx';
$mysql_table = 'xxxxxxx';
$crypt_pass = md5($_POST['password']);    <=============== Unknown Index
$found = false;
$fullname = '';
$role = '';
$avatar = '';
$session_timeout = 600;
$error_message = "";
I have two Apache based servers, one running PHP 7.3.6 and the other 7.4.9

On PHP 7.3.6, the code runs fine

On PHP 7.4.9, the code raises an "Unknown index" error and several others later on relative to the variable "password".

Any thoughts on why, I am baffled.

Jim

Re: Curious PHP issue

Posted: Fri Sep 18, 2020 2:20 pm
by Pablo
Is this code generated by one of the built-in objects?
Or did you remove code manually?

Re: Curious PHP issue

Posted: Fri Sep 18, 2020 3:17 pm
by obrienj
I apologize Pablo, this snippet is part of a combined piece of code that I forgot that I did,

Clearly, the variable password is not defined at the point that "$crypt_pass is defined.

That said, I still don't under stand why it would run on one server and not the other.

Was there some increase in error detection between 7.3.4 and 7.4.9? Or is it "php.in"i or php settings issue?

Either way, I will fix my error.

Sorry to disturb you.

Jim

Re: Curious PHP issue

Posted: Fri Sep 18, 2020 3:31 pm
by Pablo
I think newer versions of PHP are stricter, so if the $_POST variable is not set then it will trigger an error.

Re: Curious PHP issue

Posted: Sat Sep 19, 2020 1:19 pm
by obrienj
Besides stricter PHP rules, Google has been messing around with "localhost" as a domain for ReCaptcha. Which may also have something to do with it working on my web hosting site but not on my laptop with WAMP. That makes testing locally a bit of a problem.

Thanks for the help.

Jim