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?
- 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?
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:
Where is my mistake?
Thank you very much for your help.
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.
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
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
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.
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.
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.
You need to login to be able to post a reply.