hi Chrono
I am a comple newb to Joomla and have almost no PHP / MySQL knowledge... I am trying to set up a survey where each registered user fills in forms. There are going to be a number of forms, filled in at different times.
What I need to do is
A) only get each user to fill in each form once (so remember which foms each user has done)
B) save user data next to the form data (so that I can group all the forms from the same user together at the end).
I have successfully created a form, saved those fields to a database, I have registration enabled.
Any / All help would be most appreciated.
Thank you... you softawre is fantastic...
Hi bigbad,
You are going to need to write some PHP for the form html to identify the user; then to look in the table of completed forms to see what they need to do next and show them the appropriate form.
This is a pretty straight-forward piece of work provided that you know a little about PHP and Joomla.
Bob
Hi bigbad,
you can get the current form name and save it to a hidden field, and you can search teh forums for how to get current logged in user data then save it in hidden fields too, remember to save all this in the table, then you can add some form code to check on load if the form has been completed before or not, straight forward but writing code needs time!🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Thank you both for your reply...
will give it a crack and let you know how I get on.
Cheers.
Hi BB,
its not that way, first design your form and include 2 extra hidden fields inside it, user_id and formname, I prefer you add the hidden fields through HTML and not the wizard, then at the first hidden field value, add <?php echo $_GET['chronoformname']; ?> at the 2nd, add <?php $my = JFactory::getuser(); echo $my->id; ?>, now create a table and the 2 fields will appear on the table creation screen, save the table and tell me if after submit the 2 fields data are there or not
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi BB,
it should be WHERE userid="<?php $my.........; ?>"
add your own php snippet of course!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi BB,
I think you should put this code in the header :
<?php
$database->setQuery( "SELECT user_id FROM jos_chronoforms_registration2 WHERE user_id = 'some value'" );
$exists = $database->loadResult();
?>
now at the body check for exists and if its set (if isset) then display what you need, let me know if you cant fix it, give more info and I can show real code!
Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi there,
I have used this code, but it does not seem to work with me. I want do something similar. I have the user register and then log in the members area (whcih is a redirect to a CC form). The user (when logged in fiorst time) has the option to REGISTER (link to hte CF Register form) and if he has registered then it will just Say : you have registered.
I have created the Hidden fields like described that stores the ID and it works.
However when I use the above code with the ($exists) then it does not do anything. when I Echo $exist or$ database (to test output) it just gives OBJECT. 2
this is my code:
HEADER:
<?php
$user =& JFactory::getUser();
$uid = $user->id; echo $uid;
$database->setQuery( "SELECT hidden_3 FROM jos_chronoforms_MainDB WHERE $uid = $uid" ) ; echo $database;
$exists = $database->loadResult();
?>
BODY:
<?php
if (isset($exists)) {
echo '<p><font size="4" color="#333333" face="Times New Roman">Dear {name} {surname}, you have already REGISTERED.</font></p>';
} else {
echo 'blah blah blah';
}
?>
I cannot use the code in the WHERE field as if the user has not filled out the registration form he will not see this CC form.
can anyone help me?
Michael
Thanks Very much for the code,
I am a complete novice when it comes to coding. so I have one more question....
in the
$query = sprintf('SELECT COUNT(*) FROM %s WHERE $uid = %s',
section, do I add my DB instead of the first %s and then the hideden_3 for the second %s and then $uid for the last %s, where it must scan the DB in the $uid is present in the hidden_3 field?
hope you can help me
to refrase. I want the query to check if the $uid is present in the hidden_3 fields. If yes then echo and if no then echo
Michael
sprintf is an advanced string formatting tool. What it does, among other things, is replacing %s in the first string with the values of the other parameters I add to the command line (for clarity, I placed each on a subsequent line).
As such, you see two lines with $db->nameQuote, and one with $db->Quote; these are Joomla commands intended to properly quote and escape each string to make it safe. That is, to prevent SQL injection attacks.
Locate the second one, which contains the value 'cf_id' - this is the one you probably like to change into whatever table field you wish to compare against ('cf_id' is added by default by the database wizard). I believed you used 'hidden_3' for this however? If so, it's just a simple matter of changing 'cf_id' into 'hidden_3' in the code I posted, and you'd be all done.
/Fredrik
Thanks very much.
YOU ARE A STAR. It works excellent.
Thanks again
Michael
Hi there,
I have a SERIOUS problem. My CC just stopped responding. I finished all Forms and tested them all and they worked PERFECT until a few minutes ago.
NOW only 2 of my 6 of the CC Forms work. When I open the Form it just says Powered By ChronoConnectivity - ChronoEngine.com and thats it!!! It only displys the code in the Header but not the code from the Body ??? But the code is still there.
Is there anyone who knows anything about this???
PLEASE help
Michael
OK was very weird, BUT I fixed it.
I have my whole members area running on CC. I cleared my DB before so I can test further.
so when the database is empty CC will not work at all.
just for anyone who has the same problem ever. hehe
Michael
Hi Michael,
Yes, you need at least one record to show up in your list. It helps if yo add a message to say that no results have been forund. Emmanuel and I both posted ways of doing that in the CC forum recently.
Bob
Hi Bob,
I am a bit puzzled, as COUNT(*) should always return a valid result, regardless of the number of rows in the table. With or without any conditionals, the result should be zero (not null) on an empty table. Or am I overlooking something here?
/Fredrik
Hi Fredrik,
I'm not sure exactly what you are referring to - I couldn't see an obvious post in this list?
That said (and I may well be answering the wrong question) : I agree COUNT will return 0 or a positive integer.
I think that you can test with a conditional if ( $count ) because PHP will return false if $count is zero and true if $count is > zero. This uses the ambiguity between 0 and false and is equivalent to if ( $count == 0 ) as opposed to if ( $count === 0 )
Bob
Hi Bob,
Was thinking 'bout my code/the query failing to work when the data table was empty.. Re-reading the posts a few more times, I realise it was not my code that failed, but CC itself. My bad.
Regarding simplifying my test, integer 0 would be cast to boolean false, while any other integer value would be cast to true, so that would work. Just an old habit of mine, as some languages don't treat boolean cast of integers as "nicely" (-1 is a very interesting case..).
/Fredrik