Author Topic: Custom fields question  (Read 5739 times)

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« on: May 01, 2007, 01:36:11 pm »
Dear Dean Wiebe,

I think someone already asked this, but PHPBB search function really sucks.

I made an order form, with textfields, checkboxes, drop-down lists etc. (all the avalilable html form elements). I want to handle this with LM, but LM allows me only to set up textifeld as custom fields.

By signup form generation only textfields appear, how to enable other form elements?

My second question is:
I have created a custom field. By signup, LM checks for duplicate e-mails. I want the same function by this custom field, i.e lets LM to check for duplicates by this custom field.

For example, my custom field has the "xyz" value. Then by another signup the custom field has the "xyz" value, too. But in this case check wheter "xyz" already exists in database or not.

Thank for your help!

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Custom fields question
« Reply #1 on: May 02, 2007, 05:44:35 am »
Quote
By signup form generation only textfields appear, how to enable other form elements?

You can manually create the elements you require. ie:
Code: [Select]
<select name=user1>
<option value=option1>Option 1
<option value=option2>Option 2
</select>
 The final "value" is what will be passed through to ListMail and shown in a standard text input field.  Custom fields will later be expanded to be able to be set and edited in a variety of formats.
Quote
For example, my custom field has the "xyz" value. Then by another signup the custom field has the "xyz" value, too. But in this case check wheter "xyz" already exists in database or not.

There is not an easy way to do this gracefully - that is, with the appropriate error pages, etc.  Maybe there's another way.  Can you explain what this is for, exactly?

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #2 on: May 02, 2007, 07:27:07 am »
I will give you details, but first another problem...

Please help me how to signup from my php script.  My #1 list has the email, fname, user1, user2 fields. Only email and fname is required. User1 field is a domain, user2 field is an url value.

My custom php script receive these 4 data from html form: the e-mail, the first name, and user1 and user2 custom fields. I want to insert these data to listmail database. This code does not work:

Code: [Select]
<?php$domain = $_POST["user1"];$email = $_POST["email"];$name = $_POST["name"];$url = $_POST["user2"];//now I have the data, I want to insert it   $lmurl = "http://www.mydomain.com/listmail/signup.php?list=1&fname=".urlencode($name)   ."&email=".urlencode($email)."&user1=".urlencode($domain)."&user2=".urlencode($url)."&seq=1&del=0";   $lmp = fopen($lmurl,'r');   fclose($lmp);?>


If I enter the following url in the browser, then it works (with random values):

http://www.mydomain.com/listmail/signup.php?list=1&fname=asd&email=asd@asd.hu&user1=akarmi.hu&user2=httpakarmi.hu&seq=1&del=0

My php scirpt is placed in listmail folder on my host.

Sorry for lame question :)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Custom fields question
« Reply #3 on: May 02, 2007, 07:00:01 pm »
The code seems ok... Are you sure all the variables are set correctly?  Try this:
Code: [Select]
echo "domain=$domain<br>email=$email<br>name=$name<br>url=$url<br>";
Maybe you can use the curl_exec() function instead, as mentioned here:

http://listmailpro.com/forum/index.php?topic=1160.msg6365#msg6365

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #4 on: May 03, 2007, 01:55:58 am »
Thank you, now work!

So my problem is:

I have these fields in list:
email
fname
user1
user2

First, my script receive these 4 data.
Then e-mail must checked against unsubscribed and subscribed addresses.
Then user1 field must behave like e-mail: duplicates not allowed.
So user1 must checked against unsubscribed and subscribed user1 values to prevent duplicate values, like in e-mail.

I think I would use a separete database, search for email and user1 to prevent duplicates, then insert data to my database, then forward data to LM.

Can this work?

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #5 on: May 03, 2007, 01:59:10 am »
And my final question is, how to handle more than 10 custom fields?

Because my order form contains more than 10 fields. I have to write my own script again???

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Custom fields question
« Reply #6 on: May 03, 2007, 09:28:39 pm »
Quote
So user1 must checked against unsubscribed and subscribed user1 values to prevent duplicate values, like in e-mail. I think I would use a separete database

You shouldn't need an additional database since everything that needs to be checked is stored in the ListMail user table.

Consider this code, which could be called "mysignup.php" and placed in the ListMail folder:
Code: [Select]
<?phpinclude('./config.php');include('./admin.php');// check if this user1 exists in ListMail -anywhere- with any status on all listslist($exists)=@mysql_fetch_row(mysql_query("select id from $utable where user1 = '".addslashes($user1)."';"));if($exists){ // echo an error, echo a page, redirect, etc. header('Location: http://example.com');} else { // does not exist, continue with signup header("Location: http://example.com/mail/signup.php?list=$list&email=".urlencode($email) ."&fname=".urlencode($fname)."&user1=".urlencode($user1) ."&user2=".urlencode($user2));}?>

Quote
how to handle more than 10 custom fields?

At this time ListMail can only support 10 custom fields and it is non-trivial to add more...  this is eventually coming.

If you just want to store data for use in your own scripts you might consider imploding and exploding the data based on a separator string, to store more than one value in a single field.

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #7 on: May 04, 2007, 07:55:02 am »
Thank you very much, this works.

But I want to add the searching in removed e-mail function, as discussed in thread http://listmailpro.com/forum/index.php?topic=1835.0

Here is my current code:

Code: [Select]
<?phpinclude('./config.php');include('./admin.php');$domain = $_POST["domain"];$email = $_POST["email"];$name = $_POST["name"];$url = $_POST["url"];// check if this $domain exists in ListMail -anywhere- with any status on all listslist($exists)=@mysql_fetch_row(mysql_query("select id from $utable where user1 = '".addslashes($domain)."';"));if($exists){ // do nothing } else { // does not exist, continue with signup header("Location: http://www.mydomain.com/listmail/signup.php?list=2&fname=".urlencode($name)."&email=".urlencode($email)."&user1=".urlencode($domain)."&user2=".urlencode($url));}?>


Please help me extend this code:
-if the e-mail is already exists in removed addresses, then halt the singup (LM is cofigured to keep removed addresses in database)
-if the domain already exists in removed or not removed (this is already done) data, then halt the signup

Thank you!

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Custom fields question
« Reply #8 on: May 05, 2007, 12:39:22 am »
Greetings,

admin.php will automatically "make global" any POST or GET vars as well as remove magic quotes, so you can omit these lines:
Code: [Select]
$domain = $_POST["domain"];
$email = $_POST["email"];
$name = $_POST["name"];
$url = $_POST["url"];

Removed users have "cnf" set to 2, so here is the final script:
Code: [Select]
<?phpinclude('./config.php');include('./admin.php');// check if this $domain exists in ListMail -anywhere- with any status on all listslist($exists)=@mysql_fetch_row(mysql_query("select id from $utable where user1 = '".addslashes($domain)."';"));if($exists) exit();// check if this email exists in ListMail -anywhere- as a removed user on all listslist($exists)=@mysql_fetch_row(mysql_query("select id from $utable where email like '".addslashes($email)."' and cnf = '2';"));if($exists) exit();// does not exist, continue with signupheader("Location: http://www.mydomain.com/listmail/signup.php?list=2&fname=".urlencode($name)."&email=".urlencode($email)."&user1=".urlencode($domain)."&user2=".urlencode($url));?>
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #9 on: May 06, 2007, 03:18:40 pm »
Thank you very much, it works!

Dean, I have a short question: when does show the "Email Required (Signup Error & Unsub Error)" error message? If I enter NO e-mail address, then the "Bad Email Format (Signup Error & Unsub Error)" error message appers.

It seems there is a bug, because no e-mail address should trigger the email required error message.

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Custom fields question
« Reply #10 on: May 08, 2007, 12:01:13 am »
Looks like this may indeed be a bug - funny it didn't come up before...

In signup.php change this:
Code: [Select]
  if($bademails[$badlists[0]]) $msg .= emsg('email_bad',$eid).'<br>';
   elseif($rem) $msg .= emsg('email_req',$eid).'<br>';

to this:
Code: [Select]
  if($rem) $msg .= emsg('email_req',$eid).'<br>';
   elseif($bademails[$badlists[0]]) $msg .= emsg('email_bad',$eid).'<br>';

This gives priority to the 'email required' error message.

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #11 on: May 08, 2007, 08:02:18 am »
Thank you! But I'd better not modify the code :) This is only a minor bug, does not affect.

But it could be fixed in the next version.

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #12 on: May 24, 2007, 01:11:52 pm »
DEAR Dean Wiebe,

I have set up 3 custom fields. But it seems, there is a limit in custom fields: 50 characters.

If I post a data, what is more than 50 chars, then only the first 50 chars appear in custom field value. Is it true, or I do something wrong?

UPDATE:

In listmail control panel, the input text field has this html code:

Code: [Select]
<input type=text class=xbox name=user2 value="http://www.xxxxx.com/very_very_long_value_more_than_50_chars_so_truncated_9999.html" size=50 maxlength=50>

The value is correct, but the display field has the 50 chars limit. This means, that in db the data is correct? Then why is this limit by displaying?

Charybdis

  • Posts: 31
    • View Profile
Custom fields question
« Reply #13 on: May 28, 2007, 08:17:51 am »
Dear Dean Wiebe,

I use the custom insertion script.

But if the first name contains chars like these:
&+[]{} etc.

then it causes problem, even if I use the urlencode method.

Is this possible, or I did something wrong?

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Custom fields question
« Reply #14 on: May 28, 2007, 07:31:31 pm »
Greetings,
Quote
If I post a data, what is more than 50 chars, then only the first 50 chars appear in custom field value. Is it true, or I do something wrong?

This was my oversight as the maximum database field size should be increased to 65535 since v1.87d.  Please search edituser.php for "maxlength=50" - remove that option and let me know if you continue to have troubles
Quote
if the first name contains chars like these:
&+[]{} etc.

then it causes problem, even if I use the urlencode method.

Hmm, if they are urlencoded then there should be no problem.  Can I see your code?

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting