我在stackoverflow
上有一个测试注册表How do I create and store md5 passwords in mysql
我现在正试图让它在这个数组中为我正在尝试更新的现有注册表单工作。有人能让我知道我哪里出错吗?
<?
$fields_array = array();
$values_array = array();
while ($row = mysql_fetch_array($result_content)) {
switch ($row['type']) {
case 'password':
$field_value = $vars[$row['name']];
$confirm_field_value = $vars['confirm_' . $row['name']];
//start hashing and salting testing
$salt = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
$saltedPW = $field_value . $salt;
$hashedPW = hash('sha256', $saltedPW);
$field_value = $hashedPW . $salt;
//finish hashing and salting testing
break;
default:
$field_value = $vars[$row['name']];
if ($row['class'] == 'date' && $row['size'] > 0
$field_value .= ' ' . $vars[$row['name'] . 'Time'];
}
$fields_array[] = $row['name'];
$values_array[] = "'$field_value'";
}
if (count($error) == 0 && count($fields_array) > 0) {
$fields_array[] = 'created_date';
$values_array[] = "'" . date ('Y-m-d H:i:s') . "'";
$fields_array[] = 'created_ip_number';
$values_array[] = "'" . $_SERVER['REMOTE_ADDR'] . "'";
$fields = implode (", ", $fields_array);
$values = implode (", ", $values_array);
$result = $db->insertByStrings($table_title, $fields, $values)
or die('Error in ' . implode (' > ', $this_routine) . ": inserting record into $table_title failed<br/>
Query: INSERT INTO $table_title ($fields) VALUES ($values)<br/>
Error: (" . $db->getLastErrorCode() .") " . $db->getLastError());
$user_id = mysql_insert_id();
}
?>