Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    issue with $message in a form

    Hi,
    I have an issue with a form I'm trying to adapt. The validation works fine, the sending as well, but the elements from the form are not in the message.

    Here is what my code looks like:

    PHP Code:
    // Set the correct HTTP headers
    header('Content-Type: text/'.($ajax 'plain' 'html').'; charset=utf-8');

    // Extract and trim contactform values
    $ref     = isset($_POST['ref']) ? trim($_POST['ref']) : '';
    $domain  = isset($_POST['domain']) ? trim($_POST['domain']) : '';
    $name    = isset($_POST['name']) ? trim($_POST['name']) : '';
    $email   = isset($_POST['email']) ? trim($_POST['email']) : '';
    $comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';

    // Take care of magic quotes if needed (you really should have them disabled)
    set_magic_quotes_runtime(0);
    if (
    get_magic_quotes_gpc())
    {
        
    $ref     stripslashes($ref);
        
    $domain  stripslashes($domain);
        
    $name    stripslashes($name);
        
    $email   stripslashes($email);
        
    $comment stripslashes($comment);
    }

    // Initialize the errors array which will also be sent back as a JSON object
    $errors NULL;

    // Validation
    if ($email == '')
    {
        
    $errors['email'] = $config['errors']['no_email'];
    }
    elseif ( ! 
    preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD'$email))
    {
        
    $errors['email'] = $config['errors']['invalid_email'];
    }

    // Validation succeeded
    if (empty($errors))
    {
        
    $subject str_replace('%ref%'$ref$config['subject']);
        
        
    $todayis date("l, F j, Y, g:i a") ;
        
        
    // This is where I think my issue is!
        
    $message ' Date: $todayis [EST] \n
                     Nom: &name \n
                     Modele reference: &ref \n
                     Nom de domaine: &domain \n
                     Commentaire: &comment \n
                    '
    ;

        
    $headers  'Content-Type: text/plain; charset=utf-8'."\r\n";
        
    $headers .= 'From: '.$email;

        if ( ! 
    mail($config['recipient'], $subject$message$headers))
        {
            
    $errors['server'] = 'Il y a un probleme avec notre serveur, nous en sommes désolés. '.
                                
    'Envoyer votre message directement: '.$config['recipient'].'Merci.';
        }


    And I receive the following in the email (header is correct):
    Date: $todayis [EST] \n
    Nom: &name \n
    Modele reference: &ref \n
    Nom de domaine: &domain \n
    Commentaire: &comment \n

    Thanks,
    M.

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    	$message = ' Date: '.$todayis.' [EST]'."\n"
    		.'Nom: '.$name.'."\n"
    		.'Modele reference: '.$ref.'."\n"
    		.'Nom de domaine: '.$domain.'."\n"
    		.'Commentaire: '.$comment.'."\n";


  •  

    Posting Permissions

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