Restricting a Form Submission

7 posts by 3 authors in: Forums > CMS Builder
Last Post: August 20, 2012   (RSS)

Re: [gkornbluth] Restricting a Form Submission

By nmsinc - August 20, 2012

Hi Jerry,

Try using a "if" and "else statement before the submisstion button :

<?php if ($CURRENT_USER['members_only'] == "0" ): ?>

<input type="submit" value="">

<?php else: ?>

[font "Verdana"]<?php[/#000000]

[font "Verdana"]This exhibition only accepts submissions from members[/#000000]

[font "Verdana"]?>[/#000000]

[font "Verdana"]<?php endif; ?>[/#000000]
nmsinc

Re: [nmsinc] Restricting a Form Submission

By gkornbluth - August 20, 2012 - edited: August 20, 2012

Hi nmsink,

Thanks for looking at this, but in this case I don't think your approach will work. I'm tying the " members only" to a value that relates to a the specific exhibition pulled from the Master Exhibition List, not as a global value for the user.

However, once I've figured out what code needs to be in the "if" to meet the criteria, that's pretty much the format that I'll use to limit the submission.

Thanks again,

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

Re: [gkornbluth] Restricting a Form Submission

By Jason - August 20, 2012

Hi Jerry,

I think your best bet would be to limit the options in the drop down to non member records. It can be confusing to offer up and option that will never be accepted.

How about this:

<select class="validate[required]" type="text" id="project_title" name="project_title">
<option value=""><span class="body-text-bold">Select an Exhibition Name</span></option>
<?php foreach(mysql_select("master_exhibition_records", "member_only = '0'") as $exhibitionRecord): ?>
<option value="<?php echo $exhibitionRecord['title'];?>"><?php echo $exhibitionRecord['title'];?></option>

<?php endforeach?>
</select>


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] Restricting a Form Submission

What a simple and elegant solution.

One minor fix.

How would I add a second criteria to the members_only ='0'.

I'd like to add hidden = '0' so that the hidden records don't show in the options.

<?php foreach(mysql_select("master_exhibition_list", "members_only = '0'") as $exhibitionRecord): ?>

Thanks,

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

Re: [gkornbluth] Restricting a Form Submission

By Jason - August 20, 2012

Hi Jerry,

Give this a try:

<?php foreach(mysql_select("master_exhibition_list", "members_only = '0' AND hidden = '0' ") as $exhibitionRecord): ?>

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] Restricting a Form Submission

Thanks Jason,

I had the " in the wrong place and was using && instead of AND.

Works great now.

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