insert one field into two columns
i would like to insert a text field into two different columns in a database. the first one will have the original string and the second should have a string stripped of special characters.
for example:
dealer name: "joe's car lot" would insert into the corresponding column in the DB named "Dealer_Name" as well as "joescarlot" getting inserted to an additional column called "Dealer_Folder".
i have successfully stripped the characters and stored it into a variable, but do not know how to make that variable insert into the table.
The idea is that the dealer folder name for the client will not have any special characters, and it will be generated off of their name when the form is filled out.
if($_SERVER['REQUEST_METHOD']=="POST"){
$dealer_dir2 = preg_replace("/[^a-zA-Z0-9]/", "", $_POST["Dealer_Name"]);
$structure = '/Auto_Dealers/'. $dealer_dir2 .'/images';
// To create the nested structure, the $recursive parameter
// to mkdir() must be specified.
if (!mkdir($_SERVER['DOCUMENT_ROOT'] . $structure, 0, true)) {
die('Failed to create folders...that name already is being used.');
}
}
$WA_redirectURL = "/Auto_Dealers/Dealer_Login.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "Dealer_ID";
$WA_fieldNamesStr = "Contact_Number|Dealer_Folder|Account_Type|Dealer_Name|Dealer_License|Logo|Contact_Name|Business_Phone|Business_Fax|Business_Email|Business_URL|Business_Address|Business_City|Business_State|Business_ZIP|Password|Access_Level";
$WA_fieldValuesStr = "".((isset($_POST["Contact_Number"]))?$_POST["Contact_Number"]:"") ."" . "|" . "".((isset($_POST["Dealer_Folder"]))?$_POST["Dealer_Folder"]:"") ."" . "|" . "".((isset($_POST["Account_Type"]))?$_POST["Account_Type"]:"") ."" . "|" . "".((isset($_POST["Dealer_Name"]))?$_POST["Dealer_Name"]:"") ."" . "|" . "".((isset($_POST["Dealer_License"]))?$_POST["Dealer_License"]:"") ."" . "|" . "".((isset($_POST["Logo"]))?$_POST["Logo"]:"") ."" . "|" . "".((isset($_POST["Contact_Name"]))?$_POST["Contact_Name"]:"") ."" . "|" . "".((isset($_POST["Business_Phone"]))?$_POST["Business_Phone"]:"") ."" . "|" . "".((isset($_POST["Business_Fax"]))?$_POST["Business_Fax"]:"") ."" . "|" . "".((isset($_POST["Business_Email"]))?$_POST["Business_Email"]:"") ."" . "|" . "".((isset($_POST["Business_URL"]))?$_POST["Business_URL"]:"") ."" . "|" . "".((isset($_POST["Business_Address"]))?$_POST["Business_Address"]:"") ."" . "|" . "".((isset($_POST["Business_City"]))?$_POST["Business_City"]:"") ."" . "|" . "".((isset($_POST["Business_State"]))?$_POST["Business_State"]:"") ."" . "|" . "".((isset($_POST["Business_ZIP"]))?$_POST["Business_ZIP"]:"") ."" . "|" . "".((isset($_POST["Password"]))?$_POST["Password"]:"") ."" . "|" . "".((isset($_POST["Access_Level"]))?$_POST["Access_Level"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_Auto_Sales;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
any suggestions to the code would be appreciated,
thanks