1

I tried a lot but it, again and again, showing same error:

Fatal error: Uncaught Error: Array callback must have exactly two elements",

error is showing on line no.2

if($_SERVER(['REQUEST_METHOD'] == 'POST')){  
Dharman
  • 26,923
  • 21
  • 73
  • 125
  • 1
    Your script is open to [SQL Injection Attack](http://stackoverflow.com/questions/60174). Even [if you are escaping inputs, its not safe!](http://stackoverflow.com/questions/5741187) You should always use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) in either the `MYSQLI_` or `PDO` API's instead of concatenating user provided values into the query. Never trust ANY user input! – RiggsFolly Mar 12 '22 at 13:34
  • Also, ALWAYS show us ALL the error message. Thay normally come with more information than that and ALL of it can be useful – RiggsFolly Mar 12 '22 at 13:37
  • **Never** store passwords in the database as Plain Text. PHP provides [`password_hash()`](http://php.net/manual/en/function.password-hash.php) and [`password_verify()`](http://php.net/manual/en/function.password-verify.php) please use them for the safety of your users. – RiggsFolly Mar 12 '22 at 13:39
  • `$_SERVER(['REQUEST_METHOD'] == 'POST')` is not a function so code as `if ($_SERVER['REQUEST_METHOD'] == 'POST' )` – RiggsFolly Mar 12 '22 at 13:42
  • See https://stackoverflow.com/questions/37370443/fatal-error-array-callback-has-to-contain-indices-0-and-1 – Dharman Mar 14 '22 at 14:04

1 Answers1

1

$_SERVER is not a function, its an array, you need to remove () after $_SERVER, and your code will look like below

if($_SERVER['REQUEST_METHOD'] == 'POST'){ ... }

PS: as everyone said , your script is open to SQL Injection Attack and Never store passwords in the database as Plain Text. Please follow the guidelines on the comments

Tushar
  • 13,804
  • 1
  • 24
  • 44
  • Completely missed that. But this makes it a TYPO and we dont answer those. we make a comment and then close the question – RiggsFolly Mar 12 '22 at 13:41
  • Cant count this in a typo, using an `array `as a `function` is generally a conceptual fault rather than a typo. A typo would have been an unclosed brackets etc – Tushar Mar 12 '22 at 13:42