• Hey Guys,
    So I’m making an application that integrates with wordpress database. Using php, I connect to my remote database (as i dont own the server). I’m able to update and create all records of a user except for the password. The php/sql code i use to create a new user is

    <?PHP
    $dbhost = 'host';
    $dbuser = 'user';
    $dbpass = 'password';
    $user= $_GET['user'];
    $pass=$_GET['pass'];
    $name= $_GET['name'];
    $email= $_GET['email'];
    $sex= $_GET['sex'];
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
    $dbname = 'databasename';
    mysql_select_db($dbname);
    $query="INSERT INTO wp_users (user_login, user_pass, user_nicename, user_email, user_registered, display_name, user_sex)
    VALUES ('$user', MD5('$pass'), '$user', '$email', NOW(), '$name', '$sex')";
    ?>

    I pass these variables to the php file using URL. Since password in the table is encrypted I had used MD5 for encryption. To update the password through phpMyAdmin I had to use MD5 function so I tried to use the same logic for even creating/updating a password. The sql code that works with phpMyAdmin is

    UPDATE wp_users SET user_pass = MD5('password') WHERE  ID =1;

    You can see I used the same logic! But its still not working. Any help is greatly appreciated.

The topic ‘Changing/Creating password through SQL’ is closed to new replies.