Gossamer Forum
Home : Products : Links 2.0 : Customization :

Add a field in Subscribe.cgi

Quote Reply
Add a field in Subscribe.cgi
Hi,

I am trying to add a field in subscribe.cgi but what i have tried isn't working. Any help is appreciated.

As an example of what I want to do:
Right now there is email & name. I would like email & name & country

One other thing I am trying to do is have people sign up for multiple lists. I have 2 copies of links running for 2 differnet purposes. I would like one form to process both lists at once.

Any ideas??

Thanks!
Adam

[This message has been edited by anr (edited March 26, 2000).]
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Any clues at all?

Thanks!
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
If you want to add a "country" field to your email.db file, do the following:

1) Add the following codes in the sub subscribe routine in the subscribe.cgi script:

Code:
my $country = $in{'country'};

AFTER the following codes:

Code:
my $name = $in{'name'};

2) Replace the following codes:

Code:
${$users_r}{$email} = $name;

with the following codes:

Code:
${$users_r}{$email}{$country} = $name;

3) Replace the following codes:

Code:
print LIST "$_$db_delim${$users_r}{$_}\n";

with the following codes:

Code:
print LIST "$_$db_delim${$users_r}{$_}$db_delim{$country}\n";


4) Then in the sub unsubscribe routine, add the following codes:

Code:
my $country = $in{'country'};

AFTER the following codes:

Code:
my $name = $in{'name'};

5) Replace the following codes:

Code:
print LIST "$_$db_delim${$users_r}{$_}\n";

with the following codes:

Code:
print LIST "$_$db_delim${$users_r}{$_}$db_delim{$country}\n";

6) Replace the following codes in the sub get_users routine:

Code:
(/(.*)$delim(.*)/o) and (${$users_r}{$1} = $2);

with the following codes:

Code:
(/(.*)$delim(.*)/o) and (${$users_r}{$1} = $2) and (/(.*)$delim(.*)/o) and ($($country){$1} = $2);

7) Then in your email.html template file, add the following codes:

Code:
<select name="country">
<option value="Algeria">Algeria</option>
<option value="United States">United States</option>
</select>

Same thing in the email_error.html file. You will have to create your own drop-down menu with more choices, of course.

8) Then in the sub build_email_list in the db_utils.pl file, edit the following codes:

Code:
my ($name, $email, $output);

to the following:

Code:
my ($name, $email, $country, $output);

9) In the same sub-routine, edit the following codes:

Code:
($email, $name) = split /\Q:\E/;

to the following:

Code:
($email, $name, $country) = split /\Q:\E/;

I don't gaurantee these codes will work...but this is the logic that you need to be using.

Regards,



------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited March 27, 2000).]
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Number 6 is giving me the following error:

Scalar found where operator expected at subscribe.cgi line 135, at end of line
(Missing operator before ?)
syntax error at subscribe.cgi line 135, near "$($country"
syntax error at subscribe.cgi line 139, near "}"
Execution of subscribe.cgi aborted due to compilation errors.
httpd: [Mon Mar 27 23:54:24 2000] [error] [client 24.234.91.41] Premature end

Thanks!
Adam
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Edit the following codes:

Code:
(/(.*)$delim(.*)/o) and (${$users_r}{$1} = $2) and (/(.*)$delim(.*)/o) and ($($country){$1} = $2);

to the following:

Code:
(/(.*)$delim(.*)/o) and (${$users_r}{$1} = $2) and (/(.*)$delim(.*)/o) and ($country);

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Getting there:

Now the script runs but this is all that is put in the email.db

email@domain.com|HASH(0x80dad98)
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Welp...try changing the following codes:

Code:
print LIST "$_$db_delim${$users_r}{$_}\n";

to the following codes:

Code:
print LIST "$_$db_delim${$users_r}$db_delim{$country}{$_}\n";

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
referencing that line:

fatal error: not a SCALER reference.

Thanks for all the help...
Adam
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Just curious here but:

In the original script:
How does this
Code:
${$users_r}{$email} = $name;
lead to
Code:
print LIST "$_$db_delim${$users_r}{$_}\n";

I guess what I mean is there is no reference in the print line to $name. So maybe we need get $country in the line without specifiying it in there.

Quote Reply
Re: Add a field in Subscribe.cgi In reply to
If I put this:

Code:
${$users_r}{$email}{$country} = $name;

Back to this:

Code:
${$users_r}{$email} = $name;

It prints the email and name and gets rid of the hash.....
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Possibly...I am running on tons of cold medicine right now and I feel like *&^%. I can barely see the computer screen...So, please excuse any illogical or inaccurate codes I provide you.

Did you try NOT including the country variable into the PRINT statemet?

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
I know how you feel.

I did try it without the country variable but that didn't work.

It seems when you have this:
Code:
${$users_r}{$email}{$country} = $name;

it creates the hash.

One piece of warning though. It didn't effect me, but if anyone tries this - BACKUP your email.db first!!! Through all the changing that I have done, one of the last two lines (either the one above) or the print line causes the db to get erased and start fresh.
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
That is a great piece of advice that everyone should heed when moding their scripts. And I would add writing a history file of changes or put comments in your scripts.

Anyway...I really can't follow the codes right now...I am going to bed...I will try tomorrow night after work...but I think you understand at least the direction you need to take to get this working for you.

See ya.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Thanks Eliot! Take it easy.

-------
I think I figured it out.

If someone can tell me how to take
$name and $country and put it into $combo so the output looks like name|country
then I think what i did will work.
Adam
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
I GOT IT!!!

I'll let you know tomorrow or the next day exactly how. I have to go through it and get together all of the changes.

Thanks again!
Adam
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
You're welcome...

Glad you figured it out. At least I nudged ya in the right direction, right?

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Definitly. You pointed me to the right spot, and at the same time I figured out what some of the other code does. By no means do I know how to write this stuff but by playing with it a little I seem to figure out what something does and how to tinker with it a little.

Now I am just trying to figure out how to get the name and country to print in the email I generate. The Email prints fine but nothing else. (I posted a seperate question about this) I was looking at nph-email.cgi and I see how the email is printed and it looks like the name variable isn't specified. Once I can figure out the name the country should be easy.

Adam
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
[DISCLAIMER: BACKUP YOUR FILES FIRST!]

Here is what I got. I have been able to subscribe and unsubscribe and send a message (although I still haven't been able to add the persons name to the email). If there are any problems let me know....I offer no guarantees.

1) In subscribe.cgi goto sub subscribe and after this:
Code:
my $email = $in{'email'};
my $name = $in{'name'};

Add this:
Code:
my $country = $in{'country'};

2) Then change this:
Code:
${$users_r}{$email} = $name
to this:
Code:
${$users_r}{$email} = $name . "|" . $country;
3) Then in sub get_users replace this:
Code:
(/(.*)$delim(.*)/o) and (${$users_r}{$1} = $2);
with this:
Code:
(/(.*)$delim(.*)$delim(.*)/o) and (${$users_r}{$1} = $2 . "|" . $3);

That's it for subscribe.cgi We don't need to do anything to the unsubscribe section.

4) Then in the sub build_email_list in the db_utils.pl you need to replace:
Code:
my ($name, $email, $output);
with
Code:
my ($name, $email, $country, $output);
5) and
Code:
($email, $name) = split /\Q$db_delim\E/;
with
Code:
($email, $name, $country) = split /\Q$db_delim\E/;

This last line is the one that I questioned but it works. I'll let you know if there are any problems but so far testing has worked.

Also: Straight from Eliot:

6) Then in your email.html template file, add the following codes:

Code:
<select name="country">
<option value="Algeria">Algeria</option>
<option value="United States">United States</option>
</select>
Same thing in the email_error.html file. You will have to create your own drop-down menu with more choices, of course.

A special thanks to Eliot for his time and efforts. He pointed me in the right direction!

[This message has been edited by anr (edited March 30, 2000).]
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Thanks for writing out the steps that worked for you...As soon as you figure out how to add the name field into the Newsletter, you should consider posting this Mod (actually a code hack) in the Resource Center. But I would appreciate some credit in the documentation that you provide.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
Hi, your post is great, it works and is docuemted ver easy, but how do you selct the adresses to send out an mailshot with http://www.guxme.de/cgi-bin/links/admin/admin.cgi?db=links&html_mail_update=1

Do you have an example for that?

Thanks, Chris

Quote Reply
Re: Add a field in Subscribe.cgi In reply to
In Reply To:
mailshot?
What the heck is that?

Regards,

Eliot Lee
Quote Reply
Re: Add a field in Subscribe.cgi In reply to
How I have to selct the new fields for an targetet newsletter?

I need to edit nph-email.cgi ???

Chris