Link to home
Start Free TrialLog in
Avatar of plus_ec
plus_ecFlag for Ecuador

asked on

Limit number of form submissions by user with two value?

This code allow to limit the form submissions to users.
In this example I have a input box:
name=user_id
$form->data['user_id'] = &JFactory::getUser()->id;
$db_name =  $form->formXMLStruct['database']['name'];

$query = "select count(id) from $db_name where user_id={$form->data['user_id']}";
$database = &JFactory::getDBO();
$database->setQuery($query);
$res = $database->loadResult();
if ($res == null) die($query);
echo $res;
if ($res >= 10 && $form->submitter >= 0 ) $form->error = "Error!!!";//Ok, here the error message if susbmissions reach limit

Open in new window

What I need is:
First, in the above code I need to put the error message and the counter message in a text box for each one? I do not know how to translate each one in a text box.
Second,
What happens if I have another value that is necessary to know how many form submissions the user should do.
For example:
I have a select box that is populated by javascript code, this select box it's called "paralelo_box" and has this values:
A
B
C
I need to do is, if  "A" value is selected, the number of form submissions per user change, the same for "B" and "C".
In this case:
A= 10 times
B= 9 Times
C= 11 Times
And Finally:
I would like to disable the submit button if the number of form submissions reaches the limit. The name of my submit button is "finalizar".
Thanks
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

This is a strange-sounding application design.  Can you give us more of a plain-language description of the problem you are trying to solve?
SOLUTION
Avatar of plus_ec
plus_ec
Flag of Ecuador image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your English is much better than my Spanish!  I am just trying to understand the overall application design.  I have never seen such a thing and I have been around computer science for a while.  It makes me think that there is a design pattern that might be better than asking clients to choose a letter, then translating that letter into a number, etc.
Avatar of plus_ec

ASKER

yes, you are right, but which pattern you do you recommend?
Avatar of plus_ec

ASKER

What structure must be the most adecuate for designing what I asked before, as I was told my code is not the most optimal? and I need some code for guidance.
The overall idea is:
The user only access to the form with a simple password, after that, users must to choose a letter, and this letter is the key, depending on which letter the user has selected to place limitation of form submissions on each letter.
thanks.
What is the importance of asking the user to choose a letter?  Does the user know what meaning the letter conveys?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plus_ec

ASKER

Any help please!! I'm stuck
Sorry, I am just not understanding the way you want to design the application.  This appears to use Joomla, right?  If so, ask a moderator to add it to the Joomla Zone.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plus_ec

ASKER

Hi, sorry for accept my own comment as solution, but any expert comment was useful to resolved my question.
Much time has passed since the beginning of my question, and this project I have to file for the day 28/02/2011.
Having no more options, I was trying to find the answer to my way with a cool head, and it succeeds.
I recently finish my proyect.