To understand a line of PHP code about a connection

浪子不回头ぞ 提交于 2019-12-26 11:38:32

问题


What is connection() in the following code?

Code which I do understand completely

if($user->connection($email,$password)){
}

Let's assume connection() is pseudo-code. Is the pg_prepare and pg_execute` enough to create the connection?


The line caused me to omit the use of its main code in generating a login system. Subsequently, SOers pointed out severe sequrity holes in my code.

I could not find the explanation for the function connection(). The code seems to be pseudo-code to me, since the connection does not have any attributes to the database, for instance by

Example of how the connection should be formed

     $result = pg_prepare($dbconn, "query22", "SELECT passhash_md5 FROM users
         WHERE email=$1;");                                             
     $passhash_md5 = pg_execute($dbconn, "query22", array($_REQUEST['email']));                 

回答1:


$user is an instance of a class.

connection is a method in that class.

$mail & $password are parameters to that method.

This has nothing todo with arrays. what you mean would be:

$foo = array("key" => "value");

maybe this can help you: http://www.webstockbox.com/php/7-tutorials-on-how-to-create-a-php-login-system/




回答2:


I haven't actually used php.net, but this just looks like connection is a method of object $user that takes 2 params. Nothing to do with arrays.



来源:https://stackoverflow.com/questions/1266847/to-understand-a-line-of-php-code-about-a-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!