Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

RSForm!Pro - How to store the submission in a file and send it through the email

How to store the submission in a file and send it through the email

In this article we will describe how to store the submission in a file and send it through the email.

The following script will work only with the latest version of RSForm! Pro. Here's what you need to do:

  1. In the PHP Email Scripts area, type this code (either in the "Script called before the User Email is sent." area or the "Script called before the Admin Email is sent.", depending on what you require. The only difference is that you will have to use the $adminEmail variable or the $userEmail variable):

    if(isset($_POST['form']['test'])){
    $fp = fopen(JPATH_SITE.'/components/com_rsform/uploads/test.txt', 'w');
    $str = '';
    foreach($_POST['form'] as $component=>$value){
    if(is_array($value)) $value = implode(',',$value);
    $str.=$component.'='.$value."\r\n";
    }
    fwrite($fp, $str);
    fclose($fp);
    $adminEmail['files'][] = JPATH_SITE.'/components/com_rsform/uploads/test.txt';
    }

  2. Make sure that /components/com_rsform/uploads is writable.

  3. Go to the Admin Emails, and customize it similar to this:

    From: support@yourwebsite.com
    To: youradminthatreceivesthefile@yourwebsite.com

Note:

You have to fill in the rest of the email fields (leave none empty).
Here's how it will work:
1. The user submits
2. The system writes test.txt in /components/com_rsform/uploads/test.txt
3. The system attaches this file to the mail sent to the admin.

Feedback