How do you like that for a title. Hehe, it described everything I needed to ask in a brief description.
Bare with me, I’m still learning php and mySql, and having a blast with it. Every once in a while I run accross a snag and am unable to figure out the problem
Currently I am trying to set up a log in page for a user to submit a username and a password so they will be able to log in to the website. I would prefer the user to submit their own password.
I am using the “MyAdmin” secure pages, but it only allows an Admin to enter and edit users.
The table that MyAdmin uses is called “myUsers” and the fields are userName, userPass, isAdmin, userGroup, sessionID, lastLog, userRemark. I am able to insert into all of the fields with no problem except the password field.
From what I understand, the password field uses an encripted or rather “hashed” format. The MyAdmin uses the format: ” , ‘md5($_post[userPass])’ ” I’ve been trying to duplicate it, but it’s not working.
My code to insert is:
[code=php]<!– Insert values into the ***users_to_be_approved*** table ***************begin –>
<?php
// open the connection
$conn = mysql_connect(“localhost”, “***” , “***”);
// pick the database to use
mysql_select_db(“Big_File”,$conn);
// create the SQL statement
$sql = “INSERT INTO myuser_to_be_approved values (”, ‘$_POST[userName]’, ‘md5($_POST[userPass])’, ‘$_POST[isAdmin]’, ‘$_POST[userGroup]’, ‘$_POST[sessionID]’, ‘$_POST[lastLog]’, ‘$_POST[userRemark]’)”;
// execute the SQL statement
if (mysql_query($sql, $conn)) {
echo “record added!”;
} else {
echo “something went wrong”;
}
?>
Now I have tried both ways, the
[code=php]‘md5($_POST[userPass])’
and
[code=php] ‘password($_POST[userPass])’
. Each time the field results with the standard text rather than the “hashed”. For example, if my password input was “delta” the field would result “md5(delta)”
The MyAdmin will input the “Hashed” password into the field and will look something like this: “21232f297a57a5a743894a0e4a801fc3” which is apparently hexadecimal.
I’ve looked in the PHP documentation and the MySql documentation and still unable to find out what I’m doing wrong.