Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL password() function to PHP
    primarykey
    data
    text
    <p>I tried researching this but still have no answer for it. A program my friend designed writes to the MySQL db passwords using the MySQL password() function.</p> <p>I am looking for a way to use this through the web front I designed but still have no luck. Does anyone have any suggestions?</p> <p>The passwords look just like this example</p> <pre><code>mysql&gt; SET old_passwords = 0; mysql&gt; SELECT PASSWORD('mypass'); +-------------------------------------------+ | PASSWORD('mypass') | +-------------------------------------------+ | *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 | +-------------------------------------------+ </code></pre> <p>I just need to figure out how to turn this into a function i.e function password_hash</p> <p>Here's the rest the login query for an example</p> <pre><code>if (isset($_POST["username"], $_POST["password"], $_POST[$CONF["LOGIN_SIGNAL_TRIGGER"]])) { /* If we got a login signal, a password and a username, we will proceed to check login information. We will first extract the user row from the db. */ $user = myF(myQ(" SELECT `username`,`password`,`id`,`disable_until`,`active` FROM `[x]users` WHERE LCASE(`username`)='".strtolower($_POST["username"])."' ")); if (!$user["id"]) $GLOBALS["LOGIN_FAIL_TYPE"] = "e.user"; elseif ($user["active"] != 1 &amp;&amp; $CONF["LOGIN_REQUIRE_ACTIVE"]) $GLOBALS["LOGIN_FAIL_TYPE"] = "e.active"; else { /* If the user's account 'disabled' value is greater than the actual date value, and that the bruteforce protection system is enabled, we will show an error message */ if (($user["disable_until"] &gt; date("U")) &amp;&amp; ($CONF["LOGIN_BRUTEFORCE_PROTECT:ENABLE"])) { $GLOBALS["LOGIN_FAIL_TYPE"] = "e.bruteforce"; (isset($_SESSION["loginFailCount"])?session_unregister('loginFailCount'):false); } /* Account is not disabled */ else { if ((isset($_SESSION["loginFailCount"])) &amp;&amp; ($_SESSION["loginFailCount"] &gt; $CONF["LOGIN_BRUTEFORCE_FAILCOUNT"])) { myQ("UPDATE `[x]users` SET `disable_until` = ".(date("U")+$CONF["LOGIN_BRUTEFORCE_DISABLE_DURATION"])." WHERE LCASE(`username`)='".strtolower($_POST["username"])."' LIMIT 1" ); (isset($_SESSION["loginFailCount"])?session_unregister('loginFailCount'):false); $GLOBALS["LOGIN_FAIL_TYPE"] = "e.bruteforce"; } else { /* All the information correct, we will proceed to login */ if ($user["password"] == md5(trim($_POST["password"]))) { $_SESSION["id"] = (integer)$user["id"]; session_write_close(); /* Update the last login key */ $me_last_login = me("last_login"); myQ("UPDATE `[x]users` SET `last_login`='".date("U")."' WHERE `id`='".me('id')."'"); /* Route the user */ if (!$GLOBALS["WAP_MODE"]) { header("Location: ".(!$me_last_login?$CONF["LOGIN_FIRST_ROUTE_TO"]:$CONF["LOGIN_ROUTE_TO"])); } else header("Location: {$CONF["WAP_LOGIN_ROUTE_TO"]}"); } else { (isset($_SESSION["loginFailCount"])?$_SESSION["loginFailCount"]++:$_SESSION["loginFailCount"]=1); $GLOBALS["LOGIN_FAIL_TYPE"] = "e.password"; } } } } } if ((isset($_GET[$CONF["LOGOUT_SIGNAL_TRIGGER"]])) &amp;&amp; (!isset($_POST[$CONF["LOGIN_SIGNAL_TRIGGER"]]))) { /* Handle admin swapping */ if (isset($_SESSION["swap_id"])) { $_SESSION["id"] = $_SESSION["swap_id"]; session_unregister("swap_id"); header("Location: ?L=admin.index"); } else { (isset($_SESSION["id"])?session_unregister('id'):false); (isset($_SESSION["SELF_USER_DATA"])?session_unregister('SELF_USER_DATA'):false); header("Location: {$CONF["LOGOUT_ROUTE_TO"]}"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload