Click here to Skip to main content
15,867,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to make form where a user enters his device manufacturer and serial number and if it is right he is logged in. I have also set a session variable and cookie which lasts for 24 hours. But the form shows following messages on form submit:

Fatal error: Uncaught Error: Function name must be a string in /Applications/XAMPP/xamppfiles/htdocs/form/index.php:15 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/form/index.php on line 15

The PHP code is:

PHP
<?php
session_start();
$error ="";
if (array_key_exists("id", $_SESSION) OR array_key_exists("id", $_COOKIE)) {
    header("welcome.php");
}
if (array_key_exists("submit", $_POST)) {
    $link = mysqli_connect("localhost", "root", "root", "form");
    if (mysqli_connect_error()) {

        die ("Database Connection Error");

    }
    else {
        $query = "SELECT manufacturer, serial FROM `users` WHERE manufacturer = '".mysqli_real_escape_string($link, $_POST('manufacturer'))."' AND serial = '".mysqli_real_escape_string($link, $_POST('serial'))."'";
        $result = mysqli_query($link, $query);
        $row = mysqli_fetch_array($result);
        if(isset($row)) {
                $_SESSION['id'] = $row['id'];
                setcookie("id", $row['id'], time + 60*60*24);
                header("Location: welcome.php");
            }
        else {
            $error =  "Invalid data entered. Not a Pro member?";
            }
        }
    }
?>

Any ideas what I am doing wrong or what should I do?

What I have tried:

I have searched on google and also asked on stackoverflow and they didn't help. I am a newbie so I don't know enough methods to fix it.
Posted
Updated 17-Oct-18 8:26am

1 solution

The culprit is found=>
$_POST()

As it's, it was treated as a function by PHP which is non-existence.
The right form should be
$_POST[]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900