SemperFi Posted June 20, 2006 Share Posted June 20, 2006 As per the title, this is a guide on adding a field to the registration page. When all is completed, and all correct, I will write a tutorial that can hopefully be added to the tutorial section. Disclaimer : Before proceeding please backup your database and files! In this example, we are going to add a new field for customers to enter their website url upon registration. Here we go..... Step 1 - SQL Run this SQL Query ALTER TABLE Cubecart_customer ADD siteURL varchar(255) NOT NULL default ''; Step 2 - Edit includes/content/reg.inc.php Open includes/content/reg.inc.php in your favourite editor. Find : if(empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['add_1']) || empty($_POST['town']) || empty($_POST['county']) || empty($_POST['postcode']) || empty($_POST['country']) || empty($_POST['password']) || empty($_POST['passwordConf'])){ Replace With : if(empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['add_1']) || empty($_POST['town']) || empty($_POST['county']) || empty($_POST['postcode']) || empty($_POST['country']) || empty($_POST['password']) || empty($_POST['passwordConf']) || empty($_POST['siteURL'])){ Find : $record["regTime"] = $db->mySQLSafe(time()); $record["ipAddress"] = $db->mySQLSafe($_SERVER['REMOTE_ADDR']); Replace With : $record["regTime"] = $db->mySQLSafe(time()); $record["ipAddress"] = $db->mySQLSafe($_SERVER['REMOTE_ADDR']); $record["siteURL"] = $db->mySQLSafe($_POST['siteURL']); Find : $reg->assign("LANG_PLEASE_READ",$lang['front']['reg']['please_read']); Replace With : $reg->assign("LANG_PLEASE_READ",$lang['front']['reg']['please_read']); $reg->assign("LANG_SITE_URL",$lang['front']['reg']['site_url']); $reg->assign("LANG_SITE_URL_TITLE",$lang['front']['reg']['site_url_title']); Find : $reg->assign("VAL_POSTCODE",$_POST['postcode']); Replace With : $reg->assign("VAL_POSTCODE",$_POST['postcode']); $reg->assign("VAL_SITEURL",$_POST['siteURL']); Save + Upload includes/content/reg.inc.php Step 3 - Edit language/en/lang.inc.php Find : 'conf_pass' => "Confirm Password:",[code] Add this below : [code]'site_url' => "Your Website", 'site_url_title' => "Website Details", Save + Upload language/en/lang.inc.php Step 4 - Edit skins/{YOUR_SKIN}/styleTemplates/content/reg.tpl Find : <tr> <td colspan="4" class="tdcartTitle">{LANG_SECURITY_DETAILS}</td> </tr> <tr> <td>{LANG_CHOOSE_PASSWORD}</td> <td><input name="password" type="password" class="textbox" id="password" size="16" value="{VAL_PASSWORD}" tabindex="13" /> * </td> <td>{LANG_CONFIRM_PASSWORD}</td> <td><input name="passwordConf" type="password" class="textbox" id="passwordConf" size="16" value="{VAL_PASSWORD_CONF}" tabindex="14" /> * </td> </tr> Below that add this : <tr> <td colspan="4" class="tdcartTitle">{LANG_SITE_URL_TITLE}</td> </tr> <tr> <td>{LANG_SITE_URL}</td> <td><input name="siteURL" type="text" class="textbox" id="siteURL" size="16" value="{VAL_SITEURL}" tabindex="18" /> * </td> </tr> Save + Upload skins/{YOUR_SKIN}/styleTemplates/content/reg.tpl * Note you may also wish to update the tabindexs so they are sequential Step 5 - Testing! Goto www.yoursite.com/cart.php?act=reg Register a new user (fill in the new field) Check your cubecart_customer table for the new entry and data added to it. All done :) Quote Link to comment Share on other sites More sharing options...
SemperFi Posted June 20, 2006 Author Share Posted June 20, 2006 Steps for the profile page.... Step 6 - Edit includes/content/profile.inc.php Open includes/content/profile.inc.php in your favourite editor. Find: if(empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['add_1']) || empty($_POST['town']) || empty($_POST['county']) || empty($_POST['postcode']) || empty($_POST['country'])){ Replace with: if(empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['add_1']) || empty($_POST['town']) || empty($_POST['county']) || empty($_POST['postcode']) || empty($_POST['country']) || empty($_POST['siteURL'])){ Find: $data['mobile'] = $db->mySQLSafe($_POST['mobile']); Replace with: $data['mobile'] = $db->mySQLSafe($_POST['mobile']); $data['siteURL'] = $db->mySQLSafe($_POST['siteURL']); Find: $profile->assign("TXT_MOBILE",$lang['front']['profile']['mobile']); $profile->assign("VAL_MOBILE",$ccUserData[0]['mobile']); Replace with: $profile->assign("TXT_MOBILE",$lang['front']['profile']['mobile']); $profile->assign("VAL_MOBILE",$ccUserData[0]['mobile']); $profile->assign("TXT_SITEURL",$lang['front']['profile']['siteurl']); $profile->assign("VAL_SITEURL",$ccUserData[0]['siteURL']); Save + Upload includes/content/profile.inc.php Step 7 - Edit language/en/lang.inc.php Find: $lang['front']['profile'] = array( Add this below: 'siteurl' => "Your Website", Save + Upload language/en/lang.inc.php Step 8 - Edit skins/{YOUR_SKIN}/styleTemplates/content/profile.tpl Find: <tr> <td align="right"><strong>{TXT_MOBILE}</strong></td> <td><input name="mobile" type="text" class="textbox" id="mobile" value="{VAL_MOBILE}" maxlength="100" /></td> </tr> Add this below: <tr> <td align="right"><strong>{TXT_SITEURL}</strong></td> <td><input name="siteURL" type="text" class="textbox" id="siteURL" value="{VAL_SITEURL}" maxlength="100" /></td> </tr> Save + Upload skins/{YOUR_SKIN}/styleTemplates/content/profile.tpl Step 9 - Testing You guessed it....more testing Goto www.yoursite.com/index.php?act=profile and make all is working as expected. TBC..... Quote Link to comment Share on other sites More sharing options...
SemperFi Posted June 20, 2006 Author Share Posted June 20, 2006 Admin side..... Step 10 - Edit admin/customers/index.php Find: $record["phone"] = $db->mySQLSafe($_POST['phone']); Replace with: $record["phone"] = $db->mySQLSafe($_POST['phone']); $record["siteURL"] = $db->mySQLSafe($_POST['siteURL']); Find: $like .= "(email LIKE '%".$searchArray[$i]."%' OR title LIKE '%".$searchArray[$i]."%' OR firstName LIKE '%".$searchArray[$i]."%' OR lastName LIKE '%".$searchArray[$i]."%' OR add_1 LIKE '%".$searchArray[$i]."%' OR add_2 LIKE '%".$searchArray[$i]."%' OR town LIKE '%".$searchArray[$i]."%' OR county LIKE '%".$searchArray[$i]."%' OR postcode LIKE '%".$searchArray[$i]."%' OR country LIKE '%".$searchArray[$i]."%' OR phone LIKE '%".$searchArray[$i]."%' OR ipAddress LIKE '%".$searchArray[$i]."%') OR "; Replace with: $like .= "(email LIKE '%".$searchArray[$i]."%' OR title LIKE '%".$searchArray[$i]."%' OR firstName LIKE '%".$searchArray[$i]."%' OR lastName LIKE '%".$searchArray[$i]."%' OR add_1 LIKE '%".$searchArray[$i]."%' OR add_2 LIKE '%".$searchArray[$i]."%' OR town LIKE '%".$searchArray[$i]."%' OR county LIKE '%".$searchArray[$i]."%' OR postcode LIKE '%".$searchArray[$i]."%' OR country LIKE '%".$searchArray[$i]."%' OR phone LIKE '%".$searchArray[$i]."%' OR siteURL LIKE '%".$searchArray[$i]."%' OR ipAddress LIKE '%".$searchArray[$i]."%') OR "; Find: <td align="left" class="tdTitle"><?php echo $lang['admin']['customers']['email']; ?></td> Replace With: <td align="left" class="tdTitle"><?php echo $lang['admin']['customers']['email']; ?>/<?php echo $lang['admin']['customers']['siteurl']; ?></td> Find: <td class="<?php echo $cellColor; ?>"><a href="mailto:<?php echo $results[$i]['email']; ?>" class="txtLink"><?php echo $results[$i]['email']; ?></a></td> Replace With: <td class="<?php echo $cellColor; ?>"><a href="mailto:<?php echo $results[$i]['email']; ?>" class="txtLink"><?php echo $results[$i]['email']; ?></a><br><a href="url:<?php echo $results[$i]['siteURL']; ?>" class="txtLink"><?php echo $results[$i]['siteURL']; ?></a></td> Find: <tr> <td width="175" class="tdText"><?php echo $lang['admin']['customers']['email2']; ?></td> <td width="175"><input name="email" type="text" id="email" value="<?php echo $results[0]['email']; ?>" class="textbox" /></td> </tr> Add this below: <tr> <td width="175" class="tdText"><?php echo $lang['admin']['customers']['siteurl2']; ?></td> <td width="175"><input name="siteURL" type="text" id="siteURL" value="<?php echo $results[0]['siteurl']; ?>" class="textbox" /></td> </tr> Save + Upload admin/customers/index.php Step 11 - Edit language/en/lang.inc.php Find: $lang['admin']['customers'] = array ( Add this below: 'siteurl2' => "Website:", 'siteurl' => "Website", Save + Upload language/en/lang.inc.php Step 12 - Testing Goto : www.yoursite.com/admin/customers/ and test it out. Quote Link to comment Share on other sites More sharing options...
SemperFi Posted June 20, 2006 Author Share Posted June 20, 2006 *** Optional *** You only need to do this if you have installed the 'add user mod' Optional Step 1 - Edit admin/customers/add_customer.php Find: $record["mobile"] = $db->mySQLSafe($_POST['mobile']); Replace with: $record["mobile"] = $db->mySQLSafe($_POST['mobile']); $record["siteURL"] = $db->mySQLSafe($_POST['siteURL']); Find: <tr> <td class="tdRichText"><span class="copyText"><strong>Customer Email Address</strong></span></td> <td class="tdRichText" colspan="2"><input name="email" class="textbox" value="<?php if(isset($results[0]['email'])) echo $results[0]['email']; ?>" type="text" maxlength="255" /></td> </tr> Add this below: <tr> <td class="tdRichText"><span class="copyText"><strong>Customer Website Address</strong></span></td> <td class="tdRichText" colspan="2"><input name="siteURL" class="textbox" value="<?php if(isset($results[0]['siteURL'])) echo $results[0]['siteURL']; ?>" type="text" maxlength="255" /></td> </tr> Save and upload admin/customers/add_customer.php All required steps are now finished Test it out Let me know how it works / if this tutorial was of any use. :) Quote Link to comment Share on other sites More sharing options...
Guest shandaman Posted June 21, 2006 Share Posted June 21, 2006 Going to try this out ill reply back if it works. Quote Link to comment Share on other sites More sharing options...
Guest shandaman Posted June 21, 2006 Share Posted June 21, 2006 your sql string dont work for me ALTER TABLE cubecart_customer ADD siteURL varchar(255) NOT NULL default ''; should be ALTER TABLE Cubecart_customer ADD siteURL varchar(255) NOT NULL default ''; for one but other then that it still dont work. Quote Link to comment Share on other sites More sharing options...
SemperFi Posted June 21, 2006 Author Share Posted June 21, 2006 *** Edit : just noticed that a default cubecart uses Cubecart_ as a table prefix (note the uppercase). SQL code updated. You need to select the database first. Either via "use dbname;" at command line or by clicking on it via phpmyadmin Then running the SQL command. If you try and run it without selecting a your database first, you will get an error like : "ERROR 1046 (3D000): No database selected" Select your DB and try again. If you still have problems running a SQL query, you might find this page of use : http://dev.mysql.com/doc/refman/5.0/en/alter-table.html :whistle: Quote Link to comment Share on other sites More sharing options...
Guest aram Posted June 27, 2006 Share Posted June 27, 2006 Hello all! Is the possible to have the tutorial for the delivery section ? I need to put 3 extra filed to the delivery section / delivery date / delivery time / custmer comment . regards Aram Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.