I am having trouble posting the encrypted password into the database. I am also new to php and using dreamweaver for it until I get thru a book I am reading. The password is encrypting ok but it won't write to the database. I have done searches and nothing shows me how with dreamweaver to correct this. Obviously dreamweaver is a bad choice but I have no other option. Any help and explanations would be appreciated.
My code is as follows
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$password = md5 ($_POST['password']);
$sql = "insert into users values('$password')";
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "registration_FRM"))
{
$insertSQL = sprintf("INSERT INTO users (user_Name, '$password', first_Name, last_Name, zipcode, country, birth_Month, birth_Day, birth_Year, gender, email_Address) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['user_Name'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['first_Name'], "text"),
GetSQLValueString($_POST['last_Name'], "text"),
GetSQLValueString($_POST['zipcode'], "int"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['birth_Month'], "text"),
GetSQLValueString($_POST['birth_Day'], "int"),
GetSQLValueString($_POST['birth_Year'], "int"),
GetSQLValueString($_POST['gender'], "text"),
GetSQLValueString($_POST['email_Address'], "text"));
mysql_select_db($database_test $test);
$Result1 = mysql_query($insertSQL, $test) or die(mysql_error());
$insertGoTo = "registration_success.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
I placed the variable here
$insertSQL = sprintf("INSERT INTO users (user_Name, '$password', first_Name, last_Name, zipcode, country, birth_Month, birth_Day, birth_Year, gender, email_Address) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
and am getting the following error message:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''912ec803b2ce49e4a541068d495ab570', first_Name, last_Name, zipc
.
If I place the variable here
$insertSQL = sprintf("INSERT INTO users (user_Name, password, first_Name, last_Name, zipcode, country, birth_Month, birth_Day, birth_Year, gender, email_Address) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['user_Name'], "text"),
GetSQLValueString($_POST['$password'], "text"),
GetSQLValueString($_POST['first_Name'], "text"),
GetSQLValueString($_POST['last_Name'], "text"),
GetSQLValueString($_POST['zipcode'], "int"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['birth_Month'], "text"),
GetSQLValueString($_POST['birth_Day'], "int"),
GetSQLValueString($_POST['birth_Year'], "int"),
GetSQLValueString($_POST['gender'], "text"),
GetSQLValueString($_POST['email_Address'], "text"));
I get the following error message:
Column 'password' cannot be null