Lookup value in db, return associated field URL, redirect user to that URL

  • bulgin23
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 0

bulgin23 replied the topic: Lookup value in db, return associated field URL, redirect user to that URL

See the attached file .txt file which shows the full trace of a query to mysql and
breezing forms for the query:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$submittedtoken = ff_getSubmit('bfQuickModexxxxxxx');
$db->setQuery("Select url From bratly_token WHERE token =".$submittedtoken );
$urlToRedirect = $db->loadResult();
JFactory::getApplication()->redirect($urlToRedirect, 'parent');

the last part of the mysql trace is:
Query Select url From bratly_token WHERE token =

File Attachment:

File Name: mysql-trace.txt
File Size:3 KB
#234579
Attachments:
  • bulgin23
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 0

bulgin23 replied the topic: Lookup value in db, return associated field URL, redirect user to that URL

At this point I'm simply trying to get the following code to work. Other issues can wait for later.
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$submittedtoken = ff_getSubmit('bfQuickModexxxxxxx');
$db->setQuery("Select url From blaksey_token WHERE token =".$submittedtoken );
$urlToRedirect = $db->loadResult();
JFactory::getApplication()->redirect($urlToRedirect, 'parent');

Somehow the value submitted to $submittedtoken is not being captured.
#234581
  • bulgin23
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 0

bulgin23 replied the topic: Lookup value in db, return associated field URL, redirect user to that URL

Well I've solved some of the issues:

I changed the type of input field from text to number in breezing forms and I am getting re-directed properly to the proper url associated with the token. That code that is working is:
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();
$submittedtoken = ff_getSubmit('bfQuickModexxxxx');
$db->setQuery("Select url From balkesy_token WHERE token =".$submittedtoken );
$urlToRedirect = $db->loadResult();
JFactory::getApplication()->redirect($urlToRedirect, 'parent');

And my mysql database has two fields "token" and "url" both of which are varchar.

So how does someone use breezing forms - or perhaps I should ask - what should the field type be in breezing forms be ?- when you have tokens that are mixed numbers and letters so they can be compatible with a mysql varchar field?

Even with this temporary fix, the script that you so graciously provided does not work - I don't know exactly where I am supposed to put that script. Is it a drop-in replacement for the line of code you suggested I remove?

Thank you.
#234582
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1938
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: Lookup value in db, return associated field URL, redirect user to that URL

Hello,

The following code will work for a Textfield element as well:
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();
$submittedtoken = ff_getSubmit('bfQuickModexxxxx');
$db->setQuery("Select url From balkesy_token WHERE token ='$submittedtoken' " );
$urlToRedirect = $db->loadResult();
JFactory::getApplication()->redirect($urlToRedirect, 'parent');

I've tested it and it is working properly for me. Therefore, a token containing numbers and letters can be entered.

Please just make sure that "bfQuickModexxxxx" is the Name of the element where user enters token.

Let me know whether that solution works for you.

You are right, the code first suggested won't work unless "exit()" is added.
So the code to open in new tab should look like this:
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();
$submittedtoken = ff_getSubmit('bfQuickModexxxxx');
$db->setQuery("Select url From balkesy_token WHERE token ='$submittedtoken' " );
$urlToRedirect = $db->loadResult();
// JFactory::getApplication()->redirect($urlToRedirect, 'parent');

echo "<script type=\"text/javascript\">
        window.open('".$urlToRedirect."', '_blank');
    </script>";
exit();
The problem is that PHP doesn't offer itself an option to open in new tab and to echo JavaScript code the "exit()" is needed. Then the url will be opened in new tab, but the current one will be empty.

Regards,

Mihaela
#234601
The following user(s) said Thank You: bulgin23
  • bulgin23
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 0

bulgin23 replied the topic: Lookup value in db, return associated field URL, redirect user to that URL

Thank you Mihaela - your suggestion works perfectly! I will stay away from the script though because although it does the job, it leaves (as you mentioned) the user with a blank page and I'd rather that not occur. However, I will say, the excellent support on this forum and crostec and breezing forms has been outstanding. It's a good product. Probably the best forms product out there for Joomla. Thanks everyone for helping me solve this problem.
#234691
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1938
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: Lookup value in db, return associated field URL, redirect user to that URL

Hello again,

Thank you for the kind words, I'm really glad I've helped and that you like our product and support. :)

Best regards,

Mihaela
#234698
Moderators: ForumSupporttomeperica
Time to create page: 0.052 seconds

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here