Zen Cart Logo
Forums / General Questions / Help: Creating Simple Form to Post to New DB Table

Help: Creating Simple Form to Post to New DB Table

Locked

Views: 734

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
14 Dec 2010, 3:45 AM
#1
shakes222 avatar

shakes222

New Zenner

Join Date:
Aug 2010
Posts:
10
Plugin Contributions:
0

Help: Creating Simple Form to Post to New DB Table

I've toyed with the code long enough now I suppose I'll ask for a little help. I'm wanting to create a simple form on each product page, article page, a tutorial page on my site. The form data (which has been placed into hidden inputs with set values) needs to be posted to a new DB table which I have created.

I have the form completed and action set to 'process.php' which contains the INSERT query for the DB table. However, when I attempt to insert it says that either I don't have access/permission.

So what I am asking is this. Is there anyone out there can give a straight forward example to

A) the required file locations (perhaps i haven't placed the process.php in the right location)

B)outline the zen cart queries I should be using with a brief explanation (ex: does global $db; connect me to my zen cart DB or do I still need a mysql_select_db statement?)

This should be a very simple task for me to accomplish. The code needed is NOT complex at all but for whatever reason zen cart is determined not to make anything simple.

::Details::

new database table has 3 fields.

  1. favorite_id (int 11 ,auto increment)
  2. customers_id (int 11)
  3. page_url VARCHAR (255)

customers_id value is $_SESSION['customer_id']
page_url value is pretty self explanatory

I have almost punched my screen on numerous occassions and I'm hoping someone out there can save my sanity and give me a shove in the right direction.

Also, if anyone knows of any tutorials on programming for zen cart mods I would appreciate it. (I've looked through the wiki, and API but I guess I'm either missing something or it's just that helpful)

Thank you.

14 Dec 2010, 2:42 PM
#2
absolute avatar

absolute

Totally Zenned

Join Date:
May 2005
Location:
Bath, Somerset
Posts:
1,054
Plugin Contributions:
2

Re: Help: Creating Simple Form to Post to New DB Table

The quickest way to acheive what you're looking for is:

zen_db_perform('TABLE_NAME_HERE',
                        array('customers_id'  =>  (int)$_SESSION['customer_id'],
                                 'page_url'  =>  $YOUR_PAGE_VARIALBE_HERE));

This will insert directly into the table named TABLE_NAME_HERE.

There aren't really any tutorials on programming for Zen. I would suggest you get a good book on PHP, and then just start looking through the classes and functions folders, as this is where much of the stock Zen code is hidden.

Absolute

14 Dec 2010, 10:04 PM
#3
shakes222 avatar

shakes222

New Zenner

Join Date:
Aug 2010
Posts:
10
Plugin Contributions:
0

Re: Help: Creating Simple Form to Post to New DB Table

Thank you very much Absolute for your prompt response. I've recently got my hands on some PHP books to help me get started actually. Your response is much appreciated, my sanity thanks you =)