Populate fields with UN and PW

bas123 02 Aug, 2008
Hi Bob...

Max has been more than helpful in getting me started via email however due to the current server transfer, has asked me to direct questions to you.

I have located some forum posts which I believe MAY be in regards to my question, but they are so issue specific, I think it prudent to ask again here. I hope I haven't missed a post where this has been answered directly.

I have created a very nice Feedback Form including a email template and love how well it works including the field validation and CAPTCHA (love to replace the CAPTCHA image and reduce the letter length).
[attachment=0]feedback_form.jpg[/attachment]
My first question is how to pre-populate the Name & Email text boxes with the appropriate information when a member is logged in.

I currently have placed radio buttons for "Registered Member" and "Guest" (named "status"), but would rather populate those boxes with the login information.

I would further like to create a hidden field for "Username" IE: <input type="hidden" name="Username" value="<php '$Username' ?>"> so we can track the member if appropriate.

Obviously then if the submitter is a Guest, these text boxes would be empty and I'd need an "if/else" statement somewhere to send the "status" as "Guest" or "Member"

I hope I've been clear with this.

Secondly, in the FAQ's I though I had read something about modifying the form codes so that when a user makes a mistake on the ImageVerification, their inputs are retained. I spent some time with this but couldn't really figure out the explanation. and now, I can't seem to find that resource. Can you explain this process?
GreyHead 02 Aug, 2008
Hi bas123,

See this post from savant for a good explantion of getting user info with Joomla 1.5.x

You can pre-populate the name, email and status fields very easily. I'd probably pass the userid in an hidden field too.

If the user is logged in and registered then you can skip the imageverification.

To keep the submitted data on a redisplay you need to set the field values from the $_POST array. Typically this looks something like
<input type="text" name"field_name" value="<?php echo $_POST['field_name']; ?>" />
However it's more complicated to do this with radio, checkbox and select tags. The FAQ was damaged a while back and I haven't re-written it because Max tells me that the next release has this process built in. It's been due for release 'next weekend' for several weeks now but hopefully we'll see it soon.

Bob
bas123 08 Aug, 2008
Thank you,

When a member is logged in,
I now have a form which PRE-populates the "sendername" text box with the Member's name and the email text box with their registered email address ๐Ÿ˜€

I have two hidden fields with 'Username' and 'Id' all of which pass on to the email ๐Ÿ™‚ ๐Ÿ™‚

BUT,

I removed the "Status" radio buttons (Member or Guest) in favor of determining this information (for the email) by using an "if/else" statement.

I have tried the following:
In the On Submit code - before sending email: I placed...
<php?
if ($_POST[username]) == ''; {
$Status = "Guest";
} else {
$Status = "Member";
}
?>


But the email displays "Status" as "{Status}"

ALSO:

If the user is logged in and registered then you can skip the imageverification


How is this done?

I tried modifying the form with:
<?php
if ($user->username == "") {
$html = <<< EOH
<tr valign="bottom">
<td colspan="2" align="center" title="* CAPTCH is Case Sensitive" /><small>Anti-spamming protection: Please enter verification code</small><br/>{imageverification}
</td>
</tr>
EOH;
echo($html);
}
?>

Which hides the row containing the verification code if the user is logged in, BUT the onsubmit, the popup comes back with "Sorry, you have entered the wrong verification code, Please try again" and returns to the form (having lost the comments)

Finally, I would like to upgrade to the newest component(s) (my version is about 90 days old), but don't see any "upgrade" instructions. Do I simply do a regular Joomla install over the existing setup, or uninstall first, or ???


Thanks in advance for the help!
Max_admin 09 Aug, 2008
Hi bas,

too late here and so will answer your first question only for now, you should use $_POST['submit'] and not $submit only!

to upgrade to the latest BETa you will need to uninstall and redo your forms! and pay attention its for J1.5 only

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
bas123 09 Aug, 2008
Glad you're back ๐Ÿ™‚ I hope your holiday was fun!

I'll check back tomorrow for a more complete reply...
Then, I'll fix my forms per your instructions and copy and upload the new version!

Or should I install first then fix code? Hum!

Also interested in maintaining information in forms when user fails CAPTCHA. I saw this somewhere but couldn't understand instructions.
GreyHead 09 Aug, 2008
Hi bas123,

First off: Do not upload the new version unless you are prepared to recreate all of your forms. There is no way to upgrade them at present. [b]Your existing forms will not work with the new version of ChronoForms.
[/b]


Second: the only place you can create a field name that ChronoForms will recognise is the form html; so do your status calculation there using a hidden field.
<php
if ($_POST[username]) == ""; {
  $Status = "Guest";
} else {
  $Status = "Member";
}
echo "<input type='hidden' name='status' value='$status' />";
?>

Bob
bas123 10 Aug, 2008
We're making progress!

First off: Do not upload the new version unless you are prepared to recreate all of your forms. There is no way to upgrade them at present. [b]Your existing forms will not work with the new version of ChronoForms.
[/b]



Really, is this because the new system works differently? I can't save the "form html" | "On submit(s)" | "email template" codes to a file and copy/paste into the new version?

Second: the only place you can create a field name that Chronoorms will recognise is the form html; so do your status calculation there using a hidden field.

<php?
if ($_POST[username]) == ""; {
  $Status = "Guest";
} else {
  $Status = "Member";
}
echo "<input type='hidden' name='status' value='$status' />";
?>


Bob, That didn't work - first off didn't you mean "<?php" ๐Ÿคจ BUT after correcting; I got php errors

I did solve it with:
<?php
// Get user-information from Joomla
$user = &JFactory::getUser();
if ($user->id == ''){
$status = "Guest";
} else {
$status = "Member";
}
?>

And then:
<input type="hidden" name="status" id="status"
value="<?= $status; ?>" />
Later in the form...

Now, how about hiding the verification table row?

If the user is logged in and registered then you can skip the imageverification


As I said before... I can hide the row with the if/else statement, but the verification process stays ON!
Meaning a logged in member doesn't see the verification area, but after posting gets the error message.

Thanks!
GreyHead 10 Aug, 2008
Hi bas123,

I can't save the "form html" | "On submit(s)" | "email template" codes to a file and copy/paste into the new version?

Yes you can - in my book that counts as 're-creating' as you then have to reset all the other settings by hand.

You are correct in both other cases, I copied the $_POST code without thinking; and you can't avoid the imageverification without hacking chronocontact.php - I'd probably add a 'user' check in the if clause around line 194
if ( trim($paramsvalues->imagever) == 'Yes' ) {

Bob
bas123 10 Aug, 2008
Thanks Bob,

First you suggested:

If the user is logged in and registered then you can skip the imageverification



But then?

and you can't avoid the imageverification without hacking chronocontact.php - I'd probably add a 'user' check in the if clause around line 194

if ( trim($paramsvalues->imagever) == 'Yes' ) {



I am hesitant to hack the pgm especially since I will be upgrading shortly..

And am also anticipating upgrading from Joomla 1.5.3 to 1.5.5

After reading the docs on this, I am a bit reluctant about doing so. I've read of problems and different tecniques ie: upgrade to 1.5.4 first then 1.5.5

Do you guys have any thoughts on this? AND would you suggest doing the Joomla upgrade prior to the Chronoform upgrade?

Thanks!
GreyHead 11 Aug, 2008
Hi bas123,

Yes, I was wrong the first time, sorry, it happens sometimes :-) As you said, you can skip the code in the form but if validation is turned on then you will get a validation error.

I've upgraded my sites - both the test and the live sites to Joomla 1.5.5 without any problems - though I don't have any very complex extensions installed. I applied the direct upgrades some from 1.5.3 and some from 1.5.4

Personally I'd upgrade Joomla then un-install / re-install ChronoForms.

Bob
mackirony 04 May, 2009

To keep the submitted data on a redisplay you need to set the field values from the $_POST array. Typically this looks something like

<input type="text" name"field_name" value="<?php echo $_POST['field_name']; ?>" />
However it's more complicated to do this with radio, checkbox and select tags. The FAQ was damaged a while back and I haven't re-written it because Max tells me that the next release has this process built in. It's been due for release 'next weekend' for several weeks now but hopefully we'll see it soon.

Bob



Hi Bob,

Could you point me to the way how to do this with radio buttons, please?

I'm using CHRONOFORMS version 3.0.

Being able to do this would make my form 100% perfect.

Thanks!
GreyHead 04 May, 2009
Hi mackirony,

If you are on a recent release then there's a switch on the Anti_Spam tab to let ChronoForms try to republish. This is simpler than writing your own code.

Bob
mackirony 05 May, 2009
Thanks Bob,

I did a quick test and it seems to work. Even for radio buttons. You guys are amazing ;-)
This topic is locked and no more replies can be posted.