Prblems with addForm.php

9 posts by 3 authors in: Forums > CMS Builder
Last Post: July 6, 2010   (RSS)

Re: [Jeffncou] Prblems with addForm.php

By Jason - July 6, 2010

Hi,

The problem is in promotion.php. What's happening is that at the very beginning of the file, you're using this code to select your promo records:

list($promoRecords, $promoMetaData) = getRecords(array(
'tableName' => 'promo',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));

$promoRecord = @$promoRecords[0];

if (!$promoRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;


This uses the record number from the url to select a record. Once you submit the form, however, it changes the query string and the code is pulling a number from the string that is not a record number.

Could you tell me what is stored in the "promo" table? Is it a single record? Why do you only want the one record? If you could let me know what that table is used for, I can help you come up with a solution.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Prblems with addForm.php

By JeffC - July 6, 2010

Hi Jason

Thanks for the reply

The promo table could contain more than one record. It is used for competitions. There is a chance that two or more competitions may run simultaneously hence setting it up as a multi-record.

the addForm.php populates a separate table called contacts.

I use this table to collect newsletter sign ups and it also has contact details for all my clients.

I have set up a field in the contacts table called 'answer'. My idea was that someone can enter the competition by filling out the form. Their answer gets submitted to the 'answer' field. I can then export all of the correct entries using the csv export plug in.

If I have multiple competitions running at the same time I have all of the competition entries in one place.

If they choose to check the 'sign me up for a newsletter' I also have the details automatically with all of the other newsletter sign ups that have come from other sources.

Basically I have set it up this way so that I have all of my contacts in one place giving me the most flexibility when exporting the data to use with marketing campaigns

Thanks
Jeff

Re: [Jeffncou] Prblems with addForm.php

By Jason - July 6, 2010

Hi,

Okay, I think we can fix this by changing the action in the form This field won't affect how the rest of your page operates or how records are saved, but it will maintain the record number in the url so that the page loads properly after the form is submitted.

In addForm.php, add this code into the top of the form (I've highlighted the change in red):

<form method="post" action="?num=<?php echo getNumberFromEndOfUrl();?>">

Give that a try and let me know if you still run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Prblems with addForm.php

By JeffC - July 6, 2010

Hi Jason

Unfortunately that hasn't resolved the problem

Instead of going to
http://www.xxxxxx.co.uk/promotion/WIN-1

it goes to
http://www.xxxxxx.co.uk/promotion/WIN-1/?num=1
Jeff

Re: [Jeffncou] Prblems with addForm.php

By Jason - July 6, 2010

Hi,

Okay. If you could email your CMS Builder and FTP Login details to jason@interactivetools.com, I can look into this further.

Please only email this information, don't post it to the forum.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Prblems with addForm.php

By JeffC - July 6, 2010

Thank you

I have emailed the details
Jeff

Re: [Jeffncou] Prblems with addForm.php

By Jason - July 6, 2010

Hi,


I took a look at the problem. What was actually happening was when the form was being submitted, CMS Builder was adding the values from the form to the where clause. This was why it wasn't returning any records. To get around this, I added 'allowSearch' => false, to where we're getting the records.

I also took out the code we had added earlier.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jeffncou] Prblems with addForm.php

By gkornbluth - July 6, 2010

Hi jeffncou,

Interesting implementation.

Could you attach the working code so we can learn from it?

Just curious.

Have you implemented a double opt in for your newsletter signup?

best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php