After clicking the register button i am getting this error while i type those code same as yours.

0 votes
asked Nov 13, 2016 in Web Development by kaabir057 (320 points)

i am getting this error.

Notice: Undefined variable: registerUser in F:\server\htdocs\login\register.php on line 47

Fatal error: Uncaught Error: Method name must be a string in F:\server\htdocs\login\register.php:47 Stack trace: #0 {main} thrown in F:\server\htdocs\login\register.php on line 47


register.php

<?php require_once "function.php"; $user = new LoginRegistration(); ?>

<!DOCTYPE html>



Registration Pase

<body>
    <div class="wrapper">
        <div class="header">
            <h3>Login System</h3>
    </div>
    <div class="mainmenu">
        <ul>
            <li><a href="login.php">Home</a></li>
            <li><a href="">Home</a></li>
            <li><a href="">Home</a></li>
            <li><a href="">Home</a></li>
            <li><a href="">Home</a></li>
        </ul>
    </div>

    <div class="content">
        <h2>Register</h2>


    <p class="msg">
        <?php
        if($_SERVER['REQUEST_METHOD'] == 'POST'){
            $username = $_POST['username'];
            $password = $_POST['password'];
            $name = $_POST['name'];
            $email = $_POST['email'];
            $website = $_POST['website'];

            if(empty($username) or empty($password) or empty($email) or empty($website)){
                echo"<span style='color:#e53d37'>Error...Fill the empty field</span>";

            }else{
                $password = md5($password);
                $register = $user->$registerUser($username,$password,$name,$email,$website);
                if($register){
                    echo "<span style='color:green'>Register done <a href='login.php'>LOGIN NOW</a></span>";
                }else{
                    echo"<span style='color:red'>Info already exist.</span>";
                }
            }
        }
        ?>
    </p>
    <div class="login_reg">
        <form action="" method="post">
            <table>
                <tr>
                    <td>Username:</td>
                    <td><input type="text" name="username" placeholder="Enter username" /></td>
                </tr>

                <tr>
                    <td>Password:</td>
                    <td><input type="password" name="password" placeholder="Enter password" /></td>
                </tr>

                <tr>
                    <td>Name:</td>
                    <td><input type="text" name="name" placeholder="Enter name" /></td>
                </tr>

                <tr>
                    <td>Email:</td>
                    <td><input type="email" name="email" placeholder="Enter emain" /></td>
                </tr>

                <tr>
                    <td>website:</td>
                    <td><input type="text" name="website" placeholder="Enter website" /></td>
                </tr>

                <tr>
                    <td colspan="2">
                        <input type="submit" name="register" value="Register" />
                        <input type="reset" value="Reset" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

<div class="back">
    <a href="login.php"><img src="img/back.png" alt="back" /></a>
</div>

<div class="footer">
    <h3>noting</h3>
</div>
</body>
</html>

function.php

<?php
require "config.php";

class LoginRegistration{

function __construct(){
    $database = new DatabaseConnection();
}

public function registerUser($username,$password,$name,$email,$website){
    global $pdo;

    $query = $pdo->prepare("SELECT id FROM users WHERE username = ? AND email = ?");
    $query->execute(array($username, $email));
    $run = $query->rowCount();

    if($num == 0){

        $query = $pdo->prepare("INSERT INTO users (username,password,name,email,website) VALUES (?,?,?,?,?)");
        $query->execute(array($username,$password,$name,$email,$website));
        return true;
    }else{
        return print "<span style='color:#e53d37'>Error....Info already exits.!!</span>";
    }
}

}
?>

1 Answer

0 votes
answered Dec 22, 2016 by rakesh_mistry (460 points)

register.php te jekhane registerUser() a data pass korano hoyese parameter dia okhane problem ase.Object dia jokhon method call kora hoy tokhon method er age $ sign use korte hoy na. Error ta dekhlei bujha jabe. Follow this

$password = md5($password);
$register = $user->registerUser($username,$password,$name,$email,$website);

722 questions

656 answers

179 comments

4,751 users

Welcome to IDB Scholars Forum, where you can ask questions and receive answers from other members of the community. It's 100% free.
আইডিবি স্কলারস ফোরামে আপনাকে স্বাগত - প্রোগ্রামিং, ডিজাইন, ডেভেলপমেন্ট, ব্লগিং, ইন্টারনেটসহ তথ্য প্রযুক্তির যাবতীয় বিষয় নিয়ে আলোচনার একটি মুক্ত মঞ্চ হলো এই ফোরাম । এখানে আইসিটি বিষয়ক আপনার প্রশ্ন, উত্তর এবং অভিজ্ঞতা শেয়ার করুন, আলোচনা করুন এবং সমাধান নিন। দেশের তরুণ প্রজন্মকে আইসিটিতে আগ্রহী করাই আমাদের মূল লক্ষ্য।
** ইংলিশ বা বাংলা যে কোনো ভাষায় আপনি এই ফোরামে আলোচনা করতে পারবেন। তবে বাংলাকে ইংরেজি অক্ষরে লিখবেন না।
  1. tulbadex

    110 points

    0 answers

  2. AdeleMark12

    100 points

    0 answers

  3. Kawsar RRK

    100 points

    0 answers

  4. TraceeZ34069

    100 points

    0 answers

  5. stepscale54

    100 points

    0 answers

...