talkinggoat
Member
I am trying to generate a randomish string, using php and clac, that is appended to the root URL, making a unique link. The calc element is called volunteer_unique_home_url, so it is running the php on itself.
The php should check to see if the field is empty. If it's empty, it generates a unique url. If it's not empty, it returns the data from the field.
I can get php to generate the URL, no problem. My issue is, when I submit the form, it doesn't save the generated link to the DB. When I re-open the record, the link is different. Here is the php:
Save to DB is set to YES.
All the permissions are set to Public.
The element is not hidden.
Update: If I just call the $unique_url variable, it does return data and I verified there is data in the key, in mysql, so I'm confused why it won't detect there is data and skip to the else statement.
The php should check to see if the field is empty. If it's empty, it generates a unique url. If it's not empty, it returns the data from the field.
I can get php to generate the URL, no problem. My issue is, when I submit the form, it doesn't save the generated link to the DB. When I re-open the record, the link is different. Here is the php:
PHP:
$unique_url = '{user_data___volunteer_unique_home_url}';
if (empty($unique_url)) {
$username = str_shuffle(md5('{user_data___volunteer_user_name}'));
$shortened = substr($username,0,8);
return "https://mydomain.org?h=".$shortened;
} else {
return $unique_url;
}
Save to DB is set to YES.
All the permissions are set to Public.
The element is not hidden.
Update: If I just call the $unique_url variable, it does return data and I verified there is data in the key, in mysql, so I'm confused why it won't detect there is data and skip to the else statement.
Last edited: