Forums

Passing input text value using CURL not working

CRES 03 Sep, 2010
Hello,

I am working on a form for our PTO where parents can choose volunteer opportunities in their child's classroom. They need to select the teacher first and then the teacher's name will be used to create the table of opportunities.

I'm doing this by passing the input text value captured in the first form (Teacher selection) to a different form (opportunities). In the 2nd form the value is part of a SQL Query that will generate a table from a database table. The text value is captured and appears to be read correctly by CURL,
"Teacher = name"
but upon redirect I either get a parse error,

"Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$'" for the following code
<?php $name = $ _POST [\'name\']; ?>
or no error if I comment the line out, but then no table created either.

I know that it is most likely in my syntax calling the variable into the SQL Query,
<?php
$db =& JFactory::getDBO();
$query_classes = "SELECT * FROM teachers WHERE Teacher = '$name' ORDER BY `index`"; ...?>

I'd appreciate any help you could give me.

Thanks,
Marty
GreyHead 04 Sep, 2010
Hi Marty,

This sounds like a ChronoConnectivity application to me as you are trying to create a list of records (you can do it in ChronoForms, it's just the CC does some of the work for you).

I suspect that you need to remove the slashes from
<?php $name = $ _POST [\'name\']; ?>
to get that line to work; though better code might be
<?php
$name = JRequest::getString('name', '', 'post'); 
?>


I'm not at all clear where cURL comes into this though?? Is it just to pass the query info from one step to the next? Then the multi-page plug-in might be easier??

Bob
CRES 04 Sep, 2010
Bob,

Thanks for the syntax advice. I no longer get the parse error, but the table is still not being generated. Maybe I'm not passing the variable to the new form after all.

You think that I should be using Multipage? I wasn't sure that I could pass the client-side value back to the server-side php query in Multipage, so that is why I used CURL.

I'll try it, then.
Thanks,
Marty
GreyHead 04 Sep, 2010
Hi Marty,

cURL is running serverside anyhow so I don't think that would be the problem.

Bob
CRES 04 Sep, 2010
At this point it is more prudent if I stick with CURL, so long as it has the likelihood of working.

Is there a tutorial available for the CURL plugin? I do not think that I have it configured properly. I pass the varialble called name and I inserted the target URL, but the form doesn't automatically redirect to the new URL unless I place the URL address in the 'action' redirect of the 1st form. I thought that the plugin should do it. I have the plugin selected in the 1st form --should it also be selected in the 2nd form?

Sorry for the possibly silly questions.

THanks,
Marty
GreyHead 04 Sep, 2010
Hi Rose,

The cURL plug-in will transfer the data to the other page but does not transfer the user so you won't see the other page.

If you want to transfer the user then use the ReDirect plugin.

Bob
CRES 04 Sep, 2010
Thanks for the clarification. I'll try it.

Marty
CRES 04 Sep, 2010
Okay. I switched the plugin from cURL to Redirect and now I receive the following error,

$_POST: Array ( [radio0] => Hansen [Teacher] => Hansen [Load_Teacher_Table] => Submit Query [954ad40c10aa599b1a16ec173a59412a] => 1 [1cf1] => 33bec87ebec2259903064fc7077bb5da [chronoformname] => testingRadioButtons )

There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management

Iseems to ce calling the URL=http://www.colvinrunpto.org/index.php?option=com_chronocontact&chronoformname=InTheClassrm?name=Hansen&submit=

It added the '?name=Hansen&submit='
Thanks,
Marty
GreyHead 04 Sep, 2010
Hi Marty,

The $_POST display is a bug in the plug-in; there's a fixed version in the forums here.

Only this part http://www.colvinrunpto.org/index.php goes into the Target URL box - the other entries are all parameters. The fixed ones go in the text area at the bottom of the config page
option=com_chronocontact
chronoformname=InTheClassrm


Bob
CRES 04 Sep, 2010
Thanks for the direction. I found the bug fix and edited the php code. I place the form name in the correct box as it redirected well w/no errors, but still no table generation. Should I need some other code in there?

How can I verify that the value is being passed into the redirected form?

THanks.
Marty
CRES 04 Sep, 2010
While it looks like the value 'name' is being passed w/ the Redirect plugin, when I try to print it in the 2nd form using the following HTML/PHP code:

<td>Teacher = <input type="text" size="30" value="<?php $name = JRequest::getString('name', '', 'post'); ?>" /> </td>

I get a blank text field:

Teacher =

Any assistance would be appreciated.

Marty
GreyHead 04 Sep, 2010
Hi Marty,

You need an echo in there to show the result.
<?php echo JRequest::getString('name', '', 'post'); ?>


Bob
CRES 04 Sep, 2010
It is still coming up blank. I set up an Alert window after capturing the value but before passing it, and it works fine.

However, all the calls that I have configured (thanks for the code correction) on the 2nd form show 'blank'.

Where can I go from here? Is there some code that should be put in the On Submit box of the 1st form?

Marty
GreyHead 05 Sep, 2010
Hi Marty,

It probably needs to be 'get' rather than 'post' to pick up the ReDirect results.
<?php echo JRequest::getString('name', '', 'get'); ?>


Bob
CRES 05 Sep, 2010
Thanks Bob,
That was all it neeeded.
It works brilliantly now.

Thanks again,
Marty
This topic is locked and no more replies can be posted.