F
F
Flasher2015-09-25 09:52:51
PHP
Flasher, 2015-09-25 09:52:51

How to get a value from a database without passing parameters to a method?

There is an input (disabled) field in which I pass the user's first and last name from the database. Question: how can I pass the user's first and last name without passing parameters to the method, I threw in such a construction, but in this method I pass two parameters (I check soap and password), but how to rewrite the construction so as not to pass parameters, since the field should be filled in automatically when entering the page.

public function check_firstname_lastname($user_email, $user_pass) {
        if ($this->connect_db()->connect_errno) {
            die(mysqli_error($this->connect_db()));
        } else {
            $user_password = md5(md5($user_pass) . md5($user_email));
            $user_firstname_lastname = "SELECT `user_firstname`, `user_lastname` FROM `user` WHERE `user_email` = '$user_email' AND `user_password` = '$user_password'";
            return $user_firstname_lastname;
        }
    }

This is how I solved the question, I don’t know how correct it is, since I’m still a noob in php, so I want to be sure that I’m doing it right. After authorization, I drive soap into the session and when adding news, in fact, where the output of the first and last name is required, I process it like this:
public function check_firstname_lastname() {
        if ($this->connect_db()->connect_errno) {
            die(mysqli_error($this->connect_db()));
        } else {
            $user_firstname_lastname = "SELECT `user_firstname`, `user_lastname` FROM `user` WHERE `user_email` = '$_SESSION[user_email]'";
            return $user_firstname_lastname;
        }
    }

Is such an option possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-09-25
@Flasher

When authorizing a user, you can create a cookie with his id and get data in the database by id.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question