php - password issue with database change -


i changing database add "sex" column , after, can't log site. get_passwd() function, , see $passwd = $row[5] causing problem.

i fixed it, there better way function, if adding column database?

function get_passwd($link, $login) {     $sql = "select * user email='$login'";      $result = mysql_query($sql, $link);     $row = mysql_fetch_array($result);     $passwd = $row[6];//this problem!      //echo $passwd;     return $passwd; }; 

you're mysql functions deprecated. should afraid of mysql injections.


... here way make world of mysql safer ...


pdo - http://php.net/manual/de/book.pdo.php

example:

$db = new pdo("mysql:host=$db_host;dbname=$db_name;charset=utf8", "$db_user", "$db_pass"); $query = $db->prepare("select username, password user email = ? limit 1"); // should know columns selecting // limit make sure don't select 2 rows. $query->execute(array($login)); $row = $query->fetch(); echo $row["password"]; //return $row["password"]; $db = null; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -