X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Proper method for creating a new table in X-Cart 4.6.1 (https://forum.x-cart.com/showthread.php?t=76210)

simetria 05-02-2018 02:24 AM

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.

yrhazali@gmail.com 05-02-2018 03:38 AM

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.

BCSE 05-02-2018 04:30 AM

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

simetria 05-02-2018 04:45 AM

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.

BCSE 05-02-2018 09:44 AM

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

simetria 05-02-2018 09:50 AM

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

simetria 05-02-2018 09:54 AM

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

BCSE 05-02-2018 12:28 PM

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

simetria 05-02-2018 12:50 PM

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

BCSE 05-08-2018 07:07 AM

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


All times are GMT -8. The time now is 08:25 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.