Page 1 of 1

redirect from script to page

Posted: Tue Dec 04, 2012 10:51 am
by joostsoo
Hello,
I hope someone can help me with this problem.
I'm running the latest version 1.11.3
I'm building a site that needs a script to read in some data and puts that in a database. Later on this data is presented again on an other page.
I use a script to get and read the data from a database.
This all works well, only I want the output from the script placed in a page within the CMS. I tryed it with redirect and a heather redirect but without succes.
I hope someone knows how I should solf this problem
Help will be greatly appriciated. :)

Regard Joost

Re: redirect from script to page

Posted: Tue Dec 04, 2012 5:49 pm
by Wishbone
Assuming that the script is PHP, you can put the script inside a User Defined Tag. Place the tag in the page.

Re: redirect from script to page

Posted: Wed Dec 05, 2012 1:16 pm
by joostsoo
Hello
Thanks for your repley.
After removing the <php tags it works.
I have one more question regarding this.
When I come from the first page, where a selection is made, the selection is passed on to the script.
I now changed the code so the script is no longer chosen but a page with a internal link.
How can I pass on the input paramater from the selection to the UDT?
I hope this is possible.
Yhanks for your help so far
Regards Joost

Re: redirect from script to page

Posted: Wed Dec 05, 2012 2:23 pm
by Jos
You can pass parameters to a UDT like this:

UDT smarty tag:
{myUDT myparam='myvalue'}

UDT php code:
$my_parameter_value = $params['myparam'];


A simple form in a UDT can look like this (just use tag {myUDT} without parameters):

Code: Select all

if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formsubmit']))
{
   $fieldvalue = $_POST['myfield'];
   echo '<p>Thanks for your submission: ' . htmlspecialchars($fieldvalue) . '</p>';
}
else
{
   echo '<form action="" method="post">';
   echo '<input type="text" name="myfield" value="" />';
   echo '<input type="submit" name="formsubmit" value="submit" />';
   echo '</form>';
}