Categories > TinyButStrong general >

external script

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Deependra
Date: 2006-03-29
Time: 05:25

external script

i tried with my own script for processing forms in my site but i could not pass the variables - how can pass the variables?

DT
By: Skrol29
Date: 2006-03-29
Time: 13:44

Re: external script

Hello Deependra,

Coul you give more details about your problem?
By: Deependra
Date: 2006-03-29
Time: 18:28

Re: external script

i have a form in my website for mailing list subscription:

<form method="POST" action="http://localhost/bees4livelihood.icimod.org/new/suberr/sub_1.php">
<tr>
<td bgcolor="#FFFFFF" align="right">

<input type="text" name="email" size="22"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="right"><input type="submit" value="Subscribe" name="subs"></td>
</tr>
</form>

when subscribe button is pressed it has to send an email which is handled by my script:

<?php
$email=$_POST['email'];

$msg="subscribe honeybees\n";


$mailheaders .="BCC:dtandukar@icimod.org.np\n";
$mailheaders .="From:$email";

mail("majordomo@icimod.org.np", "", $msg, $mailheaders);
echo '
Your subscription request has been sent.<br>Please check your email and confirm your subscription by sending email at Majordomo@icimod.org.np with the instruction given in the email'
;
?>

here I need to pass variable $email from form to the script which i could not do, please give me some hints.

DT
By: Skrol29
Date: 2006-03-29
Time: 18:55

Re: external script

Hello Deependra,

This problem seems to have nothing to do with TinyButStrong.
However, your code seems ok to me. Variable $email should contain the string entered in the form. Did you check its contents ?
By: Deependra
Date: 2006-03-29
Time: 19:13

Re: external script

yes, i tried but the variable $email is not passed... this the code that works perfectly with my normal pages, which is my existing site... and recently i decided to move to tbs template and testing the site http://bees4livelihood.icimod.org/new/ but facing these kind of problems...

please give me some hints, when using the forms should i use the form as i normally do (for example for other static pages) or have to do something else?

By: Skrol29
Date: 2006-03-29
Time: 23:30

Re: external script

Hello Deependra,

We need more information to help you.
Regarding to the URL that you've given, it seems that to use TBS to display the message after sending the email. Could you precise how you use TBS to display this page and what are the relation between TBS and the sub_1.php script.
By: Deependra
Date: 2006-03-30
Time: 03:06

Re: external script

As i could not do like i wanted that is as in my plain site, i took another path: sub_1.php now looks like this:
<?php
$email = $_POST['email'];

if (empty($email)) {
header("Location: http://localhost/bees4livelihood.icimod.org/new/suberr/");

} else {

$msg="subscribe honeybees\n";
$mailheaders .="BCC:dtandukar@icimod.org.np\n";
$mailheaders .="From:$email";

mail("majordomo@icimod.org.np", "", $msg, $mailheaders);
echo "<html><head><meta HTTP-EQUIV=\"Refresh\" content=\"0; URL=http://localhost/bees4livelihood.icimod.org/new/sub/\"></head><body></body></html>";

}
?>

i know this is not the way it should work. if i could have some hints on how to process form like mine, it would be a great help.

DT
By: Skrol29
Date: 2006-03-31
Time: 11:35

Re: external script

Hello Deependra,

I'm sorry I can't help you since I can't understand what is not working.

I suggest that you try to scann the $_POST array to see if it contains something.  If it doesn't, then it means that the form didn't work at all, and you should look at the caller page.
TBS cannot change anything in the $_POST variable, and seems to not be involved in your script (doesn't appears anywhere).
By: Deependra
Date: 2006-04-02
Time: 16:57

Re: external script

please check at http://bees4livelihood.icimod.org/new/111/ and click on subscribe button - then i want the information to be displayed in the content area but it comes on the top of the page. Definitely, i do not know how to use such scripts in TBS, below are the codes:

it would be great if i could get a little bit of instruction on how to use such scripts.

DT

form:
<html>
<body><form method="POST" action="./sub_1.php"><span class="small">Enter your email address to subscribe.</span>
<input type="text" name="email" size="15"><input type="submit" value="Subscribe" name="subs"></form>
</body>
</html

sub_1.php
<?php

// Check if subscript's source is asked.
if (isset($_GET['subsrc'])) {
  //show_source('unsub_1.php') ;
 
  exit;
}

// Prepare variabes
if (isset($_GET['art'])) {
    $art = $_GET['art'] ;
}    else {
    $art = 1 ;
}

//$tmpl_doc = 'sub_'.$art.'.htm';

$tmpl_doc = '';
$email = $_POST['email'];

if (empty($email)) {
echo "no email";

} else {

$msg="subscribe honeybees\n";
//$mailheaders .="BCC:dtandukar@icimod.org.np\n";
$mailheaders .="From:$email";

mail("dtandukar@icimod.org.np", "", $msg, $mailheaders);
echo "$email is subscribed";

}

$tmpl_menu = 'menu.htm';
$tmpl_menubar = 'menubar.php';
$tmpl_slogan = 'slogan.php';
$tmpl_head = 'head.htm';
$dir = 'http://bees4livelihood.icimod.org/new/';

// Merging main template
include_once('../templateClass.php') ;
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('../template.php') ;
$TBS->Show() ;

?>


By: Skrol29
Date: 2006-04-02
Time: 17:24

Re: external script

Hello Deependra,

To place the information in the content, you have to save it in a variable, and place a TBS tag in your template at the place you want it to be displayed.

For exemple instead of :
echo "$email is subscribed";
Code it:
$result = "$email is subscribed";

Then, in your Html template, add:
[var.result]
or, if you may not have this variable set in under other circumstances:
[var.result;noerr]
By: Deependra
Date: 2006-04-02
Time: 19:12

Re: external script

thanks a million!!

it worked!!!