Forum Moderators: coopster
i have a form that i want to customize with radio buttons. i want members to insert their affiliate id ($rrlm) into a "text" field, then they must select 1 of 3 radios. the radio values will represent 1 to 3 urls. i'd like the
affiliate id to be inserted into the url's (site links) upon submission, if left blank, then defaults to system id.
i believe i'm on the right path with using arrays but not sure how to insert id into url's in actual html form & insert id into specific radio url represented in pdf product.
how do i write this... use multidimentional array... use switch... echo? do i create php file for form action re: array, create includes function (insert in index.php)? unfamiliar with the steps & places to put information.
Below is the idea & form html code up to this point.
Form:
First Name _____
Last Name ______
PP Email _____
CB ID _____
RRLM ID ______
RRLM Member Level
O RRLM 1
O RRLM 2
O RRLM 3
RRLM ID from the previous text filed is inserted where the
variable $RRLM inputs id in array of the selected radio.
where RRLM 1 means
"[$rrlm].company1.com";
"[$rrlm].company2.com";
"[$rrlm].company3.com";
also [$rrlm].company1.com is the specific url to be referenced
in pdf by "global subvariable" that changes according to radio
selection
where RRLM 2 means
"[$rrlm].company2.com";
"[$rrlm].company3.com";
and [$rrlm].company2.com is the specific url to be referenced in pdf
where RRLM 3 means
"[$rrlm].company3.com";
and [$rrlm].company3.com is the specific url to be referenced in pdf
array concept thus far, definitely not sure if this is right,
$RRLM[0]=
"[$rrlm].company1.com";
"[$rrlm].company2.com";
"[$rrlm].company3.com";
& "subvariable" in pdf calls up [$rrlm].company1.com
$RRLM[1]=
"[$rrlm].company2.com";
"[$rrlm].company3.com";
& "subvariable" in pdf calls up [$rrlm].company2.com
$RRLM[2]=
"[$rrlm].company3.com";
& "subvariable" in pdf calls up [$rrlm].company3.com
Basically the referral RRLM ID appears in "Learn more hyperlinks" in html form
& in pdf (# of form hyperlinks determined by radio).
For example:
If RRLM ID is typed and radio 2 is selected (mid level). After submission the behavior
should be, their RRLM ID will appear as follows:
Click to learn more about RRLM 1 (NO - default to system ID)
Click to learn more about RRLM 2 (YES)
Click to learn more about RRLM 3 (YES)
AND "Learn more...hyperlink" in the pdf, calling [$rrlm].company2.com
as
select radio 1 - RRLM ID in all links incl. pdf
select radio 3 - RRLM ID only in RRLM 3 & pdf (RRLM 1 & 2 form links
default to system ID)
current form code (where input rrlm id text, 3 radio buttons
to follow. member can only select 1 & 1 must be selected if rrlm id
is typed in):
<form action='$_SERVER[PHP_SELF]' method=post>
<p align=center>
<table style='font-size: 12px;'>
<tr><td colspan=2 align=center bgcolor=#ffffcc><b>$ttext Account</b></td></tr>
<tr><td>firstname:</td><td><input type=text name=firstname size=30 value='$user[firstname]'></td></tr>
<tr><td>lastname:</td><td><input type=text name=lastname size=30 value='$user[lastname]'></td></tr>
<tr><td>email:</td><td>$user[email]</td></tr>
<tr><td>paypal email:</td><td><input type=text name=pp size=30 value='$user[pp]'></td></tr>
<tr><td>clickbank id:</td><td><input type=text name=cb size=30 value='$user[cb]'></td></tr>
<tr><td>rrlm id:</td><td><input type=text name=rrlm size=30 value='$user[rrlm]'></td></tr>
<tr><td colspan=2><i>Leave password fields blank to keep current password.</i></td></tr>
<tr><td>password:</td><td><input type=password name=password1 size=30></td></tr>
<tr><td>confirm password:</td><td><input type=password name=password2 size=30></td></tr>
<tr><td colspan=2 align=center><input type=submit value='Update My Account'></td></tr>
</table>
<input type=hidden name=action value=account2>
<input type=hidden name=id value=$user[id]>
</p>
</form>
advice in implementing will be appreciated.
thank you for any help, suggestions or direction,
mic
I think I can be of some help with the technical aspect. Here:
$RRLM[0]=
"[$rrlm].company1.com";
"[$rrlm].company2.com";
"[$rrlm].company3.com";
I'm not understanding why you're putting [] around $rrlm and I think you'll be wanting to take them out unless they have some significance somewhere else, but to turn it into a two dimensional array:
$RRLM[0]= array(
"[$rrlm].company1.com",
"[$rrlm].company2.com",
"[$rrlm].company3.com"
);
Then the first element is $RRLM[0][0], the second is $RRLM[0][1] and the third is $RRLM[0][2]
In your form, you have to tell the php processor when to "listen", which you do with <?php ?> tags. So, for example:
<form action='<?php echo $_SERVER[PHP_SELF]; ?>' method=post>
and
<tr><td colspan=2 align=center bgcolor=#ffffcc><b><?php echo $ttext; ?> Account</b></td></tr>
I hope that helps some.
thank you for taking the time to understand my post (i was actually grappling with how to properly explain everything).
in response, yes, it's possible it can be simplified (atleast that's what my instincts have been telling me), but with my limited knowledge, i find it difficult to grab the "solution" that seems to elude me.
re: the [], this is the link format used by the script to alternate affiliate id's in the url - i.e. clicks will be split 50/50 between the system & members.
upon further reflection & reading your reply, i see your point of the two dim. array - thank you for that.
my next questions are (please be patient with me :-),
- do you think possibly the single array function is all that's required for what i'm trying to do?
you see, I need the radio to insert the affiliate's $rrlm id into all hyperlinks for their level (in form & pdf), i.e. for level 2, the affiliate $rrlm will appear in "Learn more..." hyperlinks for company2 & company3 in the form, with company2 url being the one called for the pdf.
- how should the pdf hyperlink be written so that it redirects to only one specific company url (we know the pdf hyperlink is stagnant, so how do i write the <a href.. to call / reference the appropriate $rrlm_level_url?
$rrlm_level_url can mean either $rrlm.company1.com, $rrlm.company2.com OR $rrlm.company3.com based on the radio
i came across this hyperlink example:
<a href = "<?php echo get_url()?>" <?php echo get_target_attr()?>><?php echo $text_link?></a>
- does this look right? how should i write this in an array?
- should 3 separate php files be created, each representing a specific company url? or only 1 php file with the 3 urls, explained as: using what you've provided, here's what i'm thinking: single array - radio 1 represents $RRLM[0] = array( -or- two dimensional array - radio 1 represents $RRLM[0] = array( where $rrlm[0][0] => $rrlm.company1.com i hope i haven't confused you more. the exchange is certainly leading me closer to determining the answer. thank you most sincerely, [1][edited by: Mickie at 10:36 pm (utc) on Sep. 8, 2008]
$rrlm[0][0] => $rrlm.company1.com
$rrlm[0]=> $rrlm.company2.com
$rrlm[0][2] => $rrlm.company3.com
"$rrlm.company1.com",
"$rrlm.company2.com",
"$rrlm.company3.com",
"<a href... written to call $rrlm.company1.com </a>"
);
"$rrlm.company1.com",
"$rrlm.company2.com",
"$rrlm.company3.com",
"rrlm[0][0]"
);
mic
It has one element. Also a single dimension array, two elements:
$variable[0] = "company1.com";
$variable[1] = "company2.com";
And another single dimension array which is exactly equivalent to the one above:
$variable = array("company1.com","company2.com");
This is a two dimensional array:
$variable[0][0] = "company1.com";
It too has one element, but it's two dimensional because it has two sets of [].
You're writing this form. When someone submits the form, something happens: you're performing some action in response to that submission, like saving the information somewhere, building files, emailing things. What is it that you're doing? You're saying that the radio needs to insert the affiliate's $rrlm id into all hyperlinks - where are these?
If I have this script named script.php (abridged):
<body>
<p>
<?php
if(isset($_POST['submit'])) {
$url = "http://www." . $_POST['rrlm'] . ".company1.com";
echo '<a href="' . $url . '">' . $url . '</a>';
} // endIf form submitted
else echo " ";
?>
</p>
<form action="script.php" method="post">
<div>
<input type="radio" name="rrlm" value="1" checked="checked">Company 1<br>
<input type="radio" name="rrlm" value="2">Company 2<br>
<input type="radio" name="rrlm" value="3">Company 3<br>
<input type="submit" name="submit" value="Submit">
</div>
</form>
</body>
Are we getting closer?
Ok, I purchased software that I'm making custom modifications to (primarily in regards to the $rrlm & radios, as you well know).
Here's what happens - a visitor visits optin page, subscribes to newsletter, confirms subscription & downloads free report.
Free report promotes paid report with affiliate links, if purchase is made, buyer may then create an affiliate account (via form) to insert their own id's. Upon submission, data is saved to mysql & unique affiliate url (to optin page) is created with affiliate mysql data assigned to url (form requires at least 1 id field with data).
Currently I have 8 files. The promotion hyperlinks (urls) reside in the mysql database. I'll email the account creation php for a better visual.
Best,
Mic
This does clarify some things. In your first post you asked if you needed to create new php files - that's highly unlikely. If the software generates and stores PDFs, you may need to add to those, that's still hard to say.
More than likely you want to store these generated urls somewhere. If the software already stores a single affiliate url and you're expanding it to 3 urls based on a subscription level, you could do it three ways (there's usually lots of ways but these are closest to the point, I think) in order of complexity:
Then you need to hunt down where the software retrieves the data to display/email/whatever it, and extract your extra data out with 1. explode() 2. add fields to query 3. retrieve other table row
As an example, let's say you stacked them with a comma.
When you're generating the urls, you'll look at the value of your radio buttons - let's say you named it "level", to decide which ones are system urls and which are affiliate urls.
$rrlm = $_POST['rrlm'];
if($_POST['level'] == 1) {
$url[0] = "http://$rrlm.company1.com";
$url[1] = "http://$rrlm.company2.com";
$url[2] = "http://$rrlm.company3.com";
}
elseif($_POST['level'] == 2) {
$url[0] = "http://mysystemurl.com";
$url[1] = "http://$rrlm.company2.com";
$url[2] = "http://$rrlm.company3.com";
}
else {
$url[0] = "http://mysystemurl.com";
$url[1] = "http://mysystemurl.com";
$url[2] = "http://$rrlm.company3.com";
}
$urls = implode(',',$url);
Then when you retrieve:
$tablefield = "http://www.company1.com,http://www.company2.com,http://www.company3.com";
$urls = explode(',',$tablefield);
Then $urls is a single dimension array with three elements.
How's that? Lukewarm at least?
This appears much simpler - my gut was telling it was possible, just couldn't grab hold of it - glad I posted. And yes, I plan to add the level capability to the software - something I realised in the middle of this discussion. I'll let you know the outcome.
Excellent exchange,
Mic