Passing Form Variables in URL

  • mredmond13
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 11
  • Thank you received: 0

mredmond13 created the topic: Passing Form Variables in URL

I am using BreezingForm on a Joomla site to collect criteria from users for items to include on a phone list. Upon submission, I want to pass the variables from the form to the URL that calls the PHP program to filter data to feed the phone list.

I am having a problem receiving the variables into the called PHP program.

The code used to send the variables in the URL is shown below:
$this->execPieceByName('ff_InitLib');
$addr= ff_getSubmit('IncludeAddresses');
$oots= ff_getSubmit('IncludeOOTs');
header('Location: http://www.chibr.net/member-access/phone-list?addr=$addr&oots=$oots');

The call works because prior to trying to implement the filtering, the phone list was printing fine. The URL which is sent can be seen in the following:



I wrote a simple program to see if the variables could be received. The code is below:
<?php
// ============================================================+
// File name   : index.php
// Begin         : 2019-10-02
// Updated     : 2019-10-02
// Description : Receive filter parameters and call appropriate 
//			filter and print program
// Author	      : Michael Redmond
// ============================================================+
echo "Query String = " . $_SERVER['QUERY_STRING'] . "\n";
$addr = $_GET['addr'];
if (isset($addr)) {
    echo "Include Addresses? " . "YES";
} else {
    echo "Include Addresses? " . "NO";
} 
?>

The output from this snippet of code is below:



As you can see, I cannot even get the "\n" to work.
Clearly, I am doing something wrong. Any insight would be appreciated.
Thanks.
#238039
Attachments:
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2651
  • Karma: 92
  • Thank you received: 354

mihaela replied the topic: Passing Form Variables in URL

Hello,

I think that this is not working due to the following line of code:
header('Location: http://www.chibr.net/member-access/phone-list?addr=$addr&oots=$oots');

Please try to use the following code instead:
header('Location: http://www.chibr.net/member-access/phone-list?addr='.$addr.'&oots='.$oots);

Let me know whether that resolves the problem.

Regards,

Mihaela
#238041
The following user(s) said Thank You: mredmond13
  • mredmond13
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 11
  • Thank you received: 0

mredmond13 replied the topic: Passing Form Variables in URL

mihaela wrote: I think that this is not working due to the following line of code:

header('Location: http://www.chibr.net/member-access/phone-list?addr=$addr&oots=$oots');

Please try to use the following code instead:
header('Location: http://www.chibr.net/member-access/phone-list?addr='.$addr.'&oots='.$oots);

Let me know whether that resolves the problem.

Regards,

Mihaela


It did indeed work. Thank you.

Now, can you tell me WHY it worked? Since the normal way of sending parameters is
'?param1=val1¶m2=val2' why do we here have to use the '.' method? Is that a peculiarity of BreezingForms?
#238052
  • mredmond13
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 11
  • Thank you received: 0

mredmond13 replied the topic: Passing Form Variables in URL

I was a bit too quick to say that the code is working. It's partly working.

I made the changes you suggested and I got the following:



The URL in the browser doesn't appear to be properly sending the variables as the code intends.


To check to see if the form is being read properly, I changed the SUBMIT code to the following:
$this->execPieceByName('ff_InitLib');
$addr = ff_getSubmit('IncludeAddresses');

if (!isset($addr)) {
  echo "Not Set";}
else {
  echo "Set";
}
exit();

I got the following:


So even when the box is checked, it is sending nothing. I believe the element is set correctly (see below):


As a final check, I went back to my original code (with the "&" instead of the ".", I got the same result, but the URL appears to be correct.


Any ideas?
#238056
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2651
  • Karma: 92
  • Thank you received: 354

mihaela replied the topic: Passing Form Variables in URL

Hello,

Regarding your first post, the following won't work:
header('Location: http://www.chibr.net/member-access/phone-list?addr=$addr&oots=$oots');
because you are quoting a string, so in this case the address would literally be "$addr".
So, we are using the '.' method because that is a way to concatenate a string to a variable in PHP. You can read more about it here www.php.net/manual/en/language.operators.string.php .

As for the code not working, can you please explain how do you mean that "It's partly working.". I don't see which part is working.

The following code should be working.
$this->execPieceByName('ff_InitLib');
$addr = ff_getSubmit('IncludeAddresses');

if (!isset($addr)) {
  echo "Not Set";}
else {
  echo "Set";
}
exit();

I've tested it now and in my case, it produces "Set".

Regards,

Mihaela
#238068
  • mredmond13
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 11
  • Thank you received: 0

mredmond13 replied the topic: Passing Form Variables in URL

mihaela wrote: Hello,

Regarding your first post, the following won't work:

header('Location: http://www.chibr.net/member-access/phone-list?addr=$addr&oots=$oots');
because you are quoting a string, so in this case the address would literally be "$addr".
So, we are using the '.' method because that is a way to concatenate a string to a variable in PHP. You can read more about it here www.php.net/manual/en/language.operators.string.php .

As for the code not working, can you please explain how do you mean that "It's partly working.". I don't see which part is working.

Regards,

Mihaela


The part working refers to the original question of being able to pass variables to a called program. I understand now why we need to use the dot notation.

What's still not working appears to be the ff_getSubmit construct. When executing the code you recommend, I get NOT SET regardless of what I select. It appears that the line:
$addr = ff_getSubmit('IncludeAddresses');
is not working as I erxpect it to.

The code appears to execute, but nothing is loaded into $addr. If needed, I can give DM login credentials so that you can check out the actual site.
#238076
Moderators: ForumSupporttomeperica
Time to create page: 0.956 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription 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 for just 49! (Summer Sale)

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

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