Forum Moderators: coopster

Message Too Old, No Replies

How to pass PHP variable to imported SSI function

PHP variables, SSI functions, passing variables

         

Rozey

12:35 am on Mar 28, 2004 (gmt 0)

10+ Year Member



Greetings!

I am "really green" with PHP and just starting out to comprehend the power behind the "P".

Being from the age of heavy SSI usage, I need a little bit of help converting my HTML snippets to the power of PHP.

I want to pass a php variable to a VALUE= line, assigned in my HTML coding.

How can I do that?

You see, I currently offer a newsletter from each one of my pages and like to "track the signups" by using a specific tracking tag inside the HTML being displayed on the page.

(This HTML is being served through the PHP REQUIRE command to pull in the SSI HTML file).

The problem with this is, it only inserts the HTML code that is inside the SSI file, but what I really need the HTML code to do is change according to a php variable assigned to the current page being displayed.

In the end, this would insert the php variable into the value="" field for my newsletter and a tracking tag would be in place.

I know this is possible to do, but I'm just to green to make sense out of all this PHP stuff ...but really am a fast learner!

Can anyone help me figure this out? I need help, desperately! :(

How do I make this all work as it should?

I need to know how to create a page variable that equals the name of my tracking code -- then, I need this variable inserted into the HTML code being PULLED INTO the page through SSI.

Here's my current setup:

/members/silver/index.php

I have assigned the tracking code for this specific page to be 'silver'.

Here's the newsletter txt code being inserted into the silver membership page using <?php require('/path/newsletter.txt');?>

HTML CODE:

<!--NEWSLETTER BOX -->
<table width="520" border="0" cellspacing="0" cellpadding="0">
<tr><td class="text">Receive free, fresh business and marketing articles, through the <b>Messenger Newsletter</b>, e-mailed to you weekly.
<p>You'll never be hungry for content again!</td></tr>
<tr><td>&nbsp;</td></tr>
</table>
<table width="520" border="0" cellspacing="0" cellpadding="1" bgcolor="#666699">
<tr><td>
<table width="520" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="4" height="20" bgcolor="#666699" class="text12">&nbsp;<font color="#FFFFFF">:: The Messenger</font></td></tr>
<tr>
<td width="20" bgcolor="#FFFFFF">&nbsp;</td>
<td width="420" align="center" bgcolor="#FFFFFF" valign="middle">
<form method='POST' action='http://www.marketing-seek.com/cgi-bin/arp3/arp3-formcapture.pl'>
<center>
<input type='text' name='first_name' size='10' value="First Name">
<input type='text' name='last_name' size='10' value="Last Name">
<input type='hidden' name='capitals' value='1'>
<input type='text' name='email' size='15' value="Email Address">
<input type='submit' value='Add Me »'>
</center>
<input type='hidden' name='tracking_tag' value='silver'>
<input type='hidden' name='id' value='7'>
<input type='hidden' name='extra_ar' value=''>
<input type='hidden' name='first_name_man' value='1'>
<input type='hidden' name='last_name_man' value='1'>
</form>
</td>
<td width="20" bgcolor="#FFFFFF">&nbsp;</td>
<td width="60"><img src="http://www.marketing-seek.com/images/photo_60.jpg" width="60" height="60"></td>
</tr></table>
</td></tr></table>
<!--END NEWSLETTER BOX -->

See the bolded line? This is the line that holds the tracking tag that is in question.

I need the value of this tracking tag to change according to whatever page variable is set when the page is loaded into the browser.

Then. . .

When someone signs up for the newsletter, the tracking code is sent to the autoresponder and successfully tracks where that signup came from.

Please reply at your earliest convenience and thank you kindly for any light you can shed on this dim mind...

Kindest Regards,
Rozey

Rozey

8:31 pm on Mar 28, 2004 (gmt 0)

10+ Year Member



How sad, I can't get some input on this request. :(

I thought this forum was to gain insight on how to learn PHP?

Hanu

9:04 pm on Mar 28, 2004 (gmt 0)

10+ Year Member



You talk about SSI but I don't see any SSI. Instead I see the use of PHP's
statement 'require'. Conceptually, it's equivalent but it's not called SSI. SSI
includes look like this:

<!--#include file="included.html" -->

Your post is kind of long and most people are lazy, you know. So if my answer
does not make sense to you, maybe you should reduce your example code and your
question to the minimum and then repost. Maybe you should post an excerpt of the
including code as well, not just the included file.

Anyway, here's what I understand the solution could (!) be. If you include
another PHP file, the included PHP code can access all the variables of the
including code. Even if the name of the included file ends with '.txt', it is
parsed and executed by PHP. So the bold line of your example code should read

<input type='hidden' name='tracking_tag' value='<?= $tracking_code?>'>

assuming that the variable holding the tracking code is called $tracking_code

For more about PHP statements 'include' and 'require'

[de2.php.net...]

Hanu

9:06 pm on Mar 28, 2004 (gmt 0)

10+ Year Member



Sorry, the CGI doesn't handle re-submits very well.

Rozey

3:30 am on Mar 29, 2004 (gmt 0)

10+ Year Member



Hanu,

Thanks for the reply. I figured this one out on my own... and have the PHP require code working flawlessly.

Rozey