Php whirlpool into database MySQL
#6

You should also use mysql_real_escape_string when you're dealing with custom inputs.

PHP код:
<?php  
$con 
mysql_connect("-Private-","-Private-","-Private");  
if (!
$con)  
  {  
  die(
'Could not connect: ' mysql_error());  
  }  
mysql_select_db("ThomasRdb"$con);  
$pwhash hash('whirlpool'$_POST[password]); 
$sql="INSERT INTO accounts (id, Username, Key, Email)  
VALUES  
('','" 
mysql_real_escape_string($_POST[charactername]) . "', " $pwhash ",'" mysql_real_escape_string($_POST[email]) . "')";  
if (!
mysql_query($sql,$con))  
  {  
  die(
'Error: ' mysql_error());  
  }  
echo 
"Your account has been made!";  
mysql_close($con);  
?>
Sorry to be picky but you'll thank me when someone tries to wipe your database with SQL injection.

Also, you can use $_POST straight away, you don't need to load it in to another string, see the difference:
PHP код:
$pwhash hash('whirlpool'$_POST[password]); 
in comparison to what you had before:
PHP код:
$pwhash $_POST[password]; 
$pwhash hash('whirlpool'$pwhash); 
And also you don't really need to make a string for your mysql query, but I'll stop there.
Reply


Messages In This Thread
Php whirlpool into database MySQL - by reckst4r - 14.08.2012, 18:22
Re: Php whirlpool into database MySQL - by FalconX - 14.08.2012, 18:44
Re: Php whirlpool into database MySQL - by reckst4r - 14.08.2012, 19:11
Re: Php whirlpool into database MySQL - by FalconX - 15.08.2012, 02:54
Re: Php whirlpool into database MySQL - by reckst4r - 17.08.2012, 19:56
Re: Php whirlpool into database MySQL - by Calgon - 17.08.2012, 20:00

Forum Jump:


Users browsing this thread: 1 Guest(s)