Buy Now
Sign in

how to mask an e-mail address

abiglietti@gmail.com , April 15 2021, 16:00
A
abiglietti@gmail.com 11
April 15 2021, 16:00 #396263
Hello I have the following problem:
- I have a form where the user enter a code "brnnna15..." and press a button;
- CF6 use the code to read a single row in a MySql DB Table, use the data to prepare a e-mail and send it;
- show a message to the user saying "I have found what you have asked with code "brnnna15..." and I have sent a e-mail containing your data to mickeymouse@gmail.com (email address is one of the fields read from the data base);
- this may be a privacy problem so I have to change the message in tihis way: "I have found what you have asked with code "brnnna15..." and I have sent a e-mail containing your data to m**************e@gmail.com.
- I think I can do this using php custom code before showing the message but I am unable to use the e-mail address from the database inside the custom code! I have tried a lot of syntax form but no one seems to work!!! Just as an example I copy here the last attempt:

<?php

$em = read_data12.Data12.lc_email;
$em1 = substr($em,0,1);
$el = strlen($em);
$ep = strpos ($em,"@");
$ep = $ep - 1;
$em2 = substr($em,$ep,$el);
$ec = $em1+"************"+$em2;
echo $ec;

?>
The name of the Custom Code box is EM and in the message body I have used the syntax {var:EM} to show the modified e-mail.
I have also uploaded a screenshot of my chronoform v6 page.

Can someone help me?
GreyHead 65
April 16 2021, 08:13 #396268
Hi ablglietti,
Please check this FAQ for the syntax to get form data in PHP.
Bob
If you'd like to buy me a coffee or two, thank you very much
A
abiglietti@gmail.com 11
April 16 2021, 09:15 #396269
Hi GreyHead, thank You for your answer but please note that read_data12.Data12.lc_email is not a form data field.

It is a field from a MySql DB:

- read_data12 is the name in the black box in the title of "read data" action.
- Data12 is the default value I left in the box "Model name" inside the "read data" action
- lc_email is the name of the field in MySql DB that contains the e-mail address I need to mask with "*"

I read carefully the FAQ but there is nothing about getting DataBase data in PHP.

Anyway I have tried to use this syntax suggested in the FAQ:

$em = $this->data("lc_email", "mickeymouse@gmail.com");

Values after read-data are:
 [read_data12] => Array
(
[log] => Array
(
[0] => SELECT .......
 [var] => Array
(
[Data12] => Array
(
[aid] => 314
[user_id] => 0
[created] => 2021-03-17 13:55:27
[modified] => 2021-03-17 13:55:27
.............
                            [lc_localit] => Bologna
[lc_email] => abiglietti@gmail.com
[lc_cellulare] => ......
but the value of {var:EM} is "mickeymouse@gmail.com" that is the default value I wrote in the statement $this->data(...

Where is my mistake?

Thank you very much for your help.
GreyHead 65
April 17 2021, 09:57 #396270
Hi abiglietti,
It looks as though you need Data12['lc_email'] to get the array value.
Or you could edit the DB query to just give you the email address if you don't need the other values.
Bob
If you'd like to buy me a coffee or two, thank you very much
A
abiglietti@gmail.com 11
April 20 2021, 20:47 #396281
It looks as though you need Data12['lc_email'] to get the array value.
Yes but I don't know how to get Data12['lc_email'] and assign that value to a variable $em inside a block of PHP custom code.

And how to receive the value of that variable outside of the PHP custom code.
healyhatman 9
April 22 2021, 00:04 #396284
The form value should just be the aid, not the email. That way you can display whatever you want to the user, and then read the email address out of the database again after submission.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store