Jump to content

Adding Encripted passwords


joeysarsenal

Recommended Posts

well how can i go about adding many .md5 passwords into one table my code is as

use plaincart;
#
# Table structure for table 'members'
#

CREATE TABLE `members` (
  `member_id` int(11) unsigned NOT NULL auto_increment,
  `firstname` varchar(100) default NULL,
  `lastname` varchar(100) default NULL,
  `email` varchar(100) NOT NULL,
  `city` varchar(100) NOT NULL,
  `address` varchar(100) NOT NULL,
  `postcode` varchar(100) NOT NULL,
  `login` varchar(100) NOT NULL default '',
  `passwd` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`member_id`)
) TYPE=MyISAM;



#
# Dumping data for table 'members'

 

Populating the table is below.

<?php		/* Populate The Staff Table 
	** Use an Include file to open the database
	*/

    include( "connect.inc" );

$sql = "DELETE FROM members"; //drop all data , then insert
mysql_query($sql );

$sql =  "INSERT INTO members VALUES " .
		"(NULL,'Joe','m','leboe@hotmail.com','mefsdflb','69 fook street city','4444','joe','joe'), " .
		"(NULL,'Joe1','m1','sdfdsdsf@hotmai1l.com','melfsdfb1','691 fook street city','4441','joe1','joe1')";



			if(mysql_query($sql)){
  echo("<p>client table successfully populated!</p>");	
}
else{
  print("<p>Error adding to client table: " . mysql_error() . "</p>");	
}
?>

 

at the moment its just normal words but i want it encripted and if im going to add 50 user names and passwords i would like it encripted.

I googled but no help.

 

Link to comment
Share on other sites

you can save your values in a variable, encrypt it and save it in db

 

suppose your username is Joel then

 

<?php 

$myuser = "Joel";

$myencrypteduser = md5($myuser);

///while you echo 

///you will get this 
da64a1bc2c9a53dd1cdb6846103cd2de 
?>

 

and you can insert this $myencrypteduser in the database ,

 

Link to comment
Share on other sites

n~ link=topic=163904.msg718852#msg718852 date=1192613793]

you can save your values in a variable, encrypt it and save it in db

 

suppose your username is Joel then

 

<?php 

$myuser = "Joel";

$myencrypteduser = md5($myuser);

///while you echo 

///you will get this 
da64a1bc2c9a53dd1cdb6846103cd2de 
?>

 

and you can insert this $myencrypteduser in the database ,

 

 

wouldnt i have to set another variable for the username or password for instance

like

<?php 
$myuser = "password" 
$password = "Select From Members where password = $password" (Just taking a punt here)

$myencrypteduser = md5($myuser);

///while you echo 

///you will get this 
da64a1bc2c9a53dd1cdb6846103cd2de 
?>

Not sure if thats right

but is there a way that it would grab the password field from the table.

Link to comment
Share on other sites

ok ive used neons md5 code.

is there a way i can name mulitple variables for different passwords?

<?php		/* Populate The Staff Table 
	** Use an Include file to open the database
	*/

    include( "connect.inc" );


$sql = "DELETE FROM members"; //drop all data , then insert
mysql_query($sql );

$pass = "password"; (Want more Variables here)
$passwd = md5($pass); (Need to name alot more passwords).




$sql =  "INSERT INTO members VALUES " .
		"(NULL,'Joe','m','lebo_joe@hotmail.com','melb','69 fook street city','4444','joe','$passwd'), " .
		"(NULL,'Joe1','m1','lebo_joe@hotmai1l.com','melb1','691 fook street city','4441','joe1','joe1')";



			if(mysql_query($sql)){
  echo("<p>client table successfully populated!</p>");	
}
else{
  print("<p>Error adding to client table: " . mysql_error() . "</p>");	
}
?>

Link to comment
Share on other sites

You can use any number of variable

$myuser = "Joel";
$myuser1 = "Joel1";
$myuser2 = "Joel2";
$myuser3 = "Joel3";

$myencrypteduser = md5($myuser);
$myencrypteduser1 = md5($myuser1);
$myencrypteduser2 = md5($myuser2);
$myencrypteduser3 = md5($myuser3);

 

like this

and

ok ive used neons md5 code.

 

and md5 is not mine  ;D

Link to comment
Share on other sites

lol neon i know its not urs but u helped give me the code.

Thanks thats what i wanted.

Uve been really helpful

 

i just thought if it would be possible to  do something like this

like it automatically checks the field were "passwd" is in my table and automatically encripts it. If i do it how i was before i have to encript every password and i don't know who's going to use what :P

if there isnt a way ill just have to stick to this.

Link to comment
Share on other sites

Hash in PHP, then send to DB.

$password = "test";
$passwordmd5 = md5($password);

$query ="INSERT INTO table SET username='user', password='$passwordmd5'";

Or something to that extent. You can also use the MD5 function in the DB, but then you will transfer it in plain text. You are always better off to do the complicated parts in PHP when it comes to those things.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.