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

Hello Mihaela.

I'm getting error message:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1

I have used your snippet of code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$submittedtoken = ff_getSubmit('token');
$db->setQuery("Select url From #__tablename where token =". $submittedtoken );
$urlToRedirect = $db->loadResult();

my table name is: blazey_token so I have modified the above as follows:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$submittedtoken = ff_getSubmit('token');
$db->setQuery("Select url From blazey_token where token =". $submittedtoken );
$urlToRedirect = $db->loadResult();

I am able to produce the form for input on the joomla website, but when entering the test token ab42 I receive the above error.
My backend joomla table contains the fields : ID, token, url.

Can you suggest anything?
#234517
  • 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

I solved this with the following code. Please advise if this code is safe. thank you.

$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$submittedtoken = ff_getSubmit('bfQuickMode8678584');
$db->setQuery("Select url From baksey_token WHERE token =".$submittedtoken );
$urlToRedirect = $db->loadResult();
JFactory::getApplication()->redirect($urlToRedirect, 'parent');
#234518
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

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

Hello,

I am glad that you have managed to write the correct query in order for your form to work as you wanted.

That is the regular way to query database and I think there should be no problem.

Regards,

Mihaela
#234522
  • 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. I'm trying to get the code to open the redirect in a new tab and everything I try continues to open it in the active tab:
JFactory::getApplication()->redirect($urlToRedirect, 'parent');

If I:
JFactory::getApplication()->redirect($urlToRedirect, 'blank');

still doesn't work.

What am I doing wroing?

Thank you.
#234538
  • 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

I will add that my testing is showing that once you add a captcha field to an already working form (which results in breaking the form) and then delete the captcha the form continues to not work (even though it was working prior to adding captcha).
#234543
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

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

Hello,

Please try to add this code to
echo "<script type=\"text/javascript\">
        window.open('".$urlToRedirect."', '_blank');
    </script>";
instead of:
JFactory::getApplication()->redirect($urlToRedirect, 'blank');

That should do the trick.

Let me know whether it worked.

Regarding the captcha, did you put the code in End Submit or Before submit?

Regards,

Mihaela
#234553
Moderators: ForumSupporttomeperica
Time to create page: 0.070 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