emailForm

5 posts by 3 authors in: Forums > CMS Builder
Last Post: September 22, 2014   (RSS)

By Toledoh - September 18, 2014

Hi Guys,

Just using a standard emailForm.php (attached), but I want to add a "rating" question - so a group of radio buttons.

How is the best way of implementing this, and making answering one from the group mandatory?

Cheers,

Tim (toledoh.com.au)
Attachments:

emailform.php 3K

By Toledoh - September 19, 2014

Brilliant!  Thanks!

Cheers,

Tim (toledoh.com.au)

By Jesus - September 20, 2014

I'll love to implement a comments/rating system and something like this could be a great start.

I want to have: Name/Email/Comments/Ratings on my table, and it will be great to receive an email but also, to insert this on my comments/rating table, so I can display comments and get an average rate from all rates received.

How hard will it be to implement something like this? (using this as a base), thanks in advance for sharing.

Jesus

By gregThomas - September 22, 2014

Hi Jesus, 

It would be fairly straight forward to add this feature. CMSB comes with a function called mysql_insert. This allows you to add data to a CMSB table if you have the viewer functions included in the page. Here is how you would use it:

mysql_insert($sectionName, $arrayOfData);

So the function has to variables, the CMS Builder section you're adding the data to, and an array of data to insert, with the fields as the keys, and the values as the values. Here is how you might use it for this e-mail form:

   $insertData = array();
   $insertData['fullname'] = $_REQUEST['fullname'];
   $insertData['email']    = $_REQUEST['email'];
   $insertData['message']  = $_REQUEST['message'];
   $insertData['rating']   = $_REQUEST['rating'];

   mysql_insert('email_messages', $insertData, true);

The true that has been added as the third element to the function tells it that if it doesn't have a value for a particular field (for example, created date). Then it should enter an empty value.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com