Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Proper method for creating a new table in X-Cart 4.6.1

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-02-2018, 02:24 AM
 
simetria simetria is offline
 

Advanced Member
  
Join Date: Jul 2013
Posts: 77
 

Default Proper method for creating a new table in X-Cart 4.6.1

I'm trying to create a table in the database to store some random information that does not really fit within any other existing table. I have a few questions on how to properly achieve this...

1) For X-Cart 4.6.1 can I simply create a table inside phpmyadmin, or does x-cart create tables from a php file?

2) What is the proper way to then store information in the table? Simple example: first name and last name, assuming a user already filled out the input fields and hit submit.

Thanks so much.
__________________
Thanks.
Reply With Quote
  #2  
Old 05-02-2018, 03:38 AM
 
yrhazali@gmail.com yrhazali@gmail.com is offline
    
Join Date: Sep 2017
Posts: 1
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

X-cart doesn't create Mysql Tables only for extra fields so you have to manage your new table yourself from phpmyadmin or any other tools also you have to create the .php and .tpl to store and read it.
Reply With Quote
  #3  
Old 05-02-2018, 04:30 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

1. Yes just create the table using phpmyadmin

2. You need to write php commands to put the information into the table. X-cart already has functions for this too that you can utilize. You could use the review module as an example.

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #4  
Old 05-02-2018, 04:45 AM
 
simetria simetria is offline
 

Advanced Member
  
Join Date: Jul 2013
Posts: 77
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Thanks Carrie, do you suggest creating a module structure or just use a single file? it's nothing too complicated. We just need to store some basic information.

Also were you referring to the root/modules/Advanced_Customer_Reviews/review_modify.php file when you mentioned to use the review module as an example?

Thanks.
__________________
Thanks.
Reply With Quote
  #5  
Old 05-02-2018, 09:44 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Quote:
Originally Posted by simetria
Thanks Carrie, do you suggest creating a module structure or just use a single file? it's nothing too complicated. We just need to store some basic information.

Also were you referring to the root/modules/Advanced_Customer_Reviews/review_modify.php file when you mentioned to use the review module as an example?

Thanks.

It really depends on what you're doing. Make sure you are coding to prevent SQL injection or any other ways a hacker could get in. If it's really simple, a single file would do.

Yes that file would be fine to look at examples. You just need to find a simple php example to work from.

Thanks,

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #6  
Old 05-02-2018, 09:50 AM
 
simetria simetria is offline
 

Advanced Member
  
Join Date: Jul 2013
Posts: 77
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Carrie, I tried using something like this, but it keeps redirecting me to a 403 page:

require './top.inc.php';
require './init.php';

if ($REQUEST_METHOD == 'POST') {
$fname = strip_tags(trim($_POST['fname']));
$lname =strip_tags(trim($_POST['lname']));

$query_new_data = array(
'first_name' => $fname,
'last_name' => $lname
);
func_array2insert('new_table', $query_new_data);
}

Any idea what I am missing?

-S
__________________
Thanks.
Reply With Quote
  #7  
Old 05-02-2018, 09:54 AM
 
simetria simetria is offline
 

Advanced Member
  
Join Date: Jul 2013
Posts: 77
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Never mind, I think I figured it out... I needed to register the table alias in the init.php file.

-S
__________________
Thanks.
Reply With Quote
  #8  
Old 05-02-2018, 12:28 PM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Quote:
Originally Posted by simetria
Never mind, I think I figured it out... I needed to register the table alias in the init.php file.

-S

Glad you figured it out.

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #9  
Old 05-02-2018, 12:50 PM
 
simetria simetria is offline
 

Advanced Member
  
Join Date: Jul 2013
Posts: 77
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Carrie, one thing that confuses me is how x-cart handles the data before it gets sent to the database. I'm pretty familiar in using PDO and MYSQLI with prepared statements, but going through the modules and seeing what they do to sanitize/validate/strip is confusing to me.

Does strip_tags suffice? Do I need to use mysqli_real_escape_string? Something else?

What is X-Cart using as a database function PDO or MYSQLI?

Whats the desired convention in preparing data to either be stored, modified, deleted, or queried?

I tried also looking through the docs and couldn't not land on any page that would answer these questions for me.

Thanks again!!!!

-S
__________________
Thanks.
Reply With Quote
  #10  
Old 05-08-2018, 07:07 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,091
 

Default Re: Proper method for creating a new table in X-Cart 4.6.1

Sorry I got really busy the past week and haven't been able to get on the forums much. Did you get it figured out?

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:02 AM.

   

 
X-Cart forums © 2001-2020