close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

insert one field into two columns

Thread began 2/10/2011 10:21 pm by davidp420108 | Last modified 2/11/2011 1:13 am by Dave Buchholz | 935 views | 1 replies |

davidp420108

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

Sign in to reply to this post

Dave BuchholzBeta Tester

Assuming you want to insert the variable $dealer_dir2 in the wizard you would simply enter <?php echo $dealer_dir2; ?> instead of selecting the POST value

You can type anything you like into the wizard fields as long as it matches the above format in my experience

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...