• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Retrieve customer info before sending downloadlink to E-mail address

Hi,

I need to be able to retrieve customer information when a customer wants to download mij application.
The following fields are required on the form (all fields must be entered):
* Companyname
* Name
* E-mail
* Phone

Following fields must be set in code:
FROM-E-mail address: myemail@mydomain.com
Subject: some text
Body: some text in the E-mail containing a.o. a downloadlink to retrieve the software.

The customer enters these field.
The "download"-button is pressed.
A E-mail with downloadlink is sent to the entered E-mailaddress.
A copy of this E-mail is also sent to the FROM-E-mailaddress

The entered fields need to be stored in a MYSQL DB:
Tablename:
- Downloads
Fields:
- DownloadDate (always set to today)
- Email
- Company
- Name
- Phone

Can anybody supply me with a working code example?
0
Stef Merlijn
Asked:
Stef Merlijn
1 Solution
 
Ray PaseurCommented:
This is not really a question so much as a need for custom application development, and for that you should hire a developer.  It has parts of several well-known design patterns, including form-to-email, data validation, and registration+handshake.  

Here is a registration+handshake article:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_3939-Registration-and-Email-Confirmation-in-PHP.html

The code snippet contains an example of form-to-email.  HTH, ~Ray
<?php // RAY_form_to_email.php
error_reporting(E_ALL);


// SEND MAIL FROM A FORM


// A FUNCTION TO CLEAN UP THE DATA - AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    $str = stripslashes($str);
    $str = trim(preg_replace("/ +/", " ", $str));
    $str = preg_replace('/^ a-zA-Z0-9&+:?_\.\-/', '', $str);
    return $str;
}


// REQUIRED VALUES ARE PREPOPULATED - CHANGE THESE FOR YOUR WORK
$from  = "NoReply@Your.org";
$subj  = "Contact Form";

// THIS IS AN ARRAY OF RECIPIENTS
$to[]  = "You@Your.org";
$to[]  = "Her@Your.org";
$to[]  = "Him@Your.org";

// IF THE DATA HAS BEEN POSTED
if (!empty($_POST['email']))
{
    // CLEAN UP THE POTENTIALLY BAD AND DANGEROUS DATA
    $email      = clean_string($_POST["email"]);
    $name       = clean_string($_POST["name"]);
    $telephone  = clean_string($_POST["telephone"]);

    // CONSTRUCT THE MESSAGE
    $content    = '';
    $content   .= "You have a New Query From $name" . PHP_EOL . PHP_EOL;
    $content   .= "Tel No: $telephone" . PHP_EOL;
    $content   .= "Email: $email" . PHP_EOL;

    // SEND MAIL TO EACH RECIPIENT
    foreach ($to as $recipient)
    {
        if (!mail( $recipient, $subj, $content, "From: $from\r\n"))
        {
            echo "MAIL FAILED FOR $recipient";
        }
        else
        {
            echo "MAIL WORKED FOR $recipient";
        }
    }
} // END OF PHP - PUT UP THE FORM
?>
<form method="post">
<br/>Email: <input name="email" />
<br/>Phone: <input name="telephone" />
<br/>Name:  <input name="name" />
<br/><input type="submit" />
</form>

Open in new window

0
 
Stef MerlijnDeveloperAuthor Commented:
It has pointed me in the right direction. Thank you very much!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now