www.webdeveloper.com
Results 1 to 3 of 3

Thread: Receive all the fields of a contact form in the mail

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Exclamation Receive all the fields of a contact form in the mail

    Hello gang,

    I created a website including a contact form, which is essential.
    URL : http://www.biosculpturegel-paca.fr/

    In the demo file, there were only 4 fields. In mine, there are 9. These extra informations are for a client. Demo site : http://demo.cepreu.net/enfolio/

    I edited the custom.js and ajax-functions.php to add these extra field in the code of tyhese documents. However, these new informations are nowhere to be seen in the mails I received via the contact form.

    I started with PHP and Javascript like today so that's pretty new to me.

    Could a good sould take a look at these short documents and tell me whats' wrong pretty please ? You would rock even more.

    custom.js : custom.js
    jquery.plugins.min.js (I didn't touch this one but maybe we should look inside it too) : jquery.plugins.min.js
    index.html : index.html

    I couldn't upload the ajax-functions.php file to my server and provide a proper URL so I'll paste the code here :

    PHP Code:
    <?php

    $name 
    $_POST['name'];
    $raison $_POST['raison'];
    $siret $_POST['siret'];
    $from $_POST['email'];
    $newsletter $_POST['newsletter'];
    $phone $_POST['phone'];
    $site $_POST['site'];
    $subject $_POST['subject'];
    $message $_POST['message'];

    $to 'contact@biosculpturegel-paca.fr'// contact@biosculpturegel-paca.fr
    $valid_referers = array(
            
    'http://biosculpturegel-paca.fr/',    // the URL to your page without www prefix
            
    'http://www.biosculpturegel-paca.fr/'    // the URL to your page with www prefix
    );

    $headers 'From:' .$name'<' .$from">\r\n" .
                
    'Reply-To: '.$from."\r\n" .
                
    'X-Mailer: PHP/' phpversion();

    if (
    $_SERVER['REQUEST_METHOD'] == 'POST' && in_array($_SERVER['HTTP_REFERER'], $valid_referers)) {

        if (!
    mail($to$subject$message$headers)) {
            exit;
        };
        
        die(
    'ok');

    };

    ?>

  2. #2
    Join Date
    Oct 2007
    Posts
    371
    I didn't read your files except for the code you pasted, but what you probably need to do is use what's called the "Concatenation Operator". In PHP it is the period and in JS it's the Plus Sign. It tacks strings together.

    Example
    PHP Code:
    $a='Hello';
    $b='World';
    $c=$a.' '.$b;
    echo 
    $c;
    //Hello World 
    I'd do
    PHP Code:
    $message $_POST['message'];
    $message .=$_POST['fieldname']."\n";
    $message .=$_POST['otherfieldname']."\n";
    $message .=$_POST['anotherfieldname']."\n"
    the "\n" is a line break. It has to be in double quotes, not single quotes, or PHP won't interpret it. If your message in in HTML format then change it to ."<br>\n"

  3. #3
    Join Date
    Jan 2012
    Posts
    2
    Quote Originally Posted by TecBrat View Post
    I didn't read your files except for the code you pasted, but what you probably need to do is use what's called the "Concatenation Operator". In PHP it is the period and in JS it's the Plus Sign. It tacks strings together.

    Example
    PHP Code:
    $a='Hello';
    $b='World';
    $c=$a.' '.$b;
    echo 
    $c;
    //Hello World 
    I'd do
    PHP Code:
    $message $_POST['message'];
    $message .=$_POST['fieldname']."\n";
    $message .=$_POST['otherfieldname']."\n";
    $message .=$_POST['anotherfieldname']."\n"
    the "\n" is a line break. It has to be in double quotes, not single quotes, or PHP won't interpret it. If your message in in HTML format then change it to ."<br>\n"
    Thank you TecBrat for your help. I will try what you said. Thank you again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles