SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I modify this mail script

    I am new to PHP and dont know where to start with customizing my own php mail form from a template.

    I have got my contact mail form working which was based on Dustin Diaz's template, you can see my contact form here.

    I am trying to customize Dustin Diaz's script to work with my quote php mail page which will be part of the same site.

    I am just trying to modify the quote php processing page but its not working yet and I am not sure if I am on the right track yet or if the direction my customization is going is totally wrong.

    PHP Code:
    <?php
    // Change the 4 variables below
    $yourName 'admin@precisionhomes.com.au';
    $yourEmail 'admin@precisionhomes.com.au';
    $yourSubject 'Contact Form';
    $referringPage 'http://www.precisionhomes.com.au';
    // No need to edit below unless you really want to. It's using a simple php mail() function. Use your own if you want
    function cleanPosUrl ($str) {
    return 
    stripslashes($str);
    }
        if ( isset(
    $_POST['sendContactEmail']) )
        {
        
    $to $yourEmail;
        
    $subject $yourSubject.': '.$_POST['posRegard'];
        
    $message cleanPosUrl($_POST['posText']);
        
    $headers "From: ".cleanPosUrl($_POST['posName'])." <".$_POST['posEmail'].">\r\n";
        
    $headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
        
    $title cleanPosUrl($_POST['posTitle']);
        
    $fname cleanPosUrl($_POST['posFName']);
        
    $lname cleanPosUrl($_POST['posLName']);
        
    $street cleanPosUrl($_POST['posStreet']);
        
    $suburb cleanPosUrl($_POST['posSuburb']);
        
    $postcode cleanPosUrl($_POST['posPostcode']);
        
    $homephone cleanPosUrl($_POST['posHomePhone']);
        
    $mobile cleanPosUrl($_POST['posMobile']);
        
    $fax cleanPosUrl($_POST['posFax']);
        
    $email cleanPosUrl($_POST['posEmail']);
        
    $email cleanPosUrl($_POST['select']);
        
    $reason cleanPosUrl($_POST['enqReason']);
        
    $budget cleanPosUrl($_POST['enqBudget']);
        
    $comments cleanPosUrl($_POST['enqComment']);
        
    $advert cleanPosUrl($_POST['select2']);
        
    $otherad cleanPosUrl($_POST['enqAdOther']);
        
    $mail->Body "

    Title: 
    $title

    First Name: 
    $fname 

    Last Name: 
    $lname

    Street Address: 
    $street

    Suburb: 
    $suburb

    Postcode: 
    $postcode

    Home Phone number: 
    $homephone

    Mobile number: 
    $mobile

    Fax number: 
    $fax

    Email Address: 
    $email

    Preferred Method of Contact: 
    $select

    Reason for Enquiry: 
    $reason

    Proposed Budget: 
    $budget

    Comments: 
    $comments

    Where did you hear about us: 
    $advert

    I heard about you from somewhere that is not on the above list: 
    $otherad";

        
    $mailit mail($to,$subject,$message,$headers$mail);
            if ( @
    $mailit ) {
            
    header('Location: '.$referringPage.'?success=true');
            }
            else {
            
    header('Location: '.$referringPage.'?error=true');
            }
        }
    ?>
    This is the original working code from Dustin Diaz's contact form

    PHP Code:
    <?php
    // Change the 4 variables below
    $yourName 'admin@precisionhomes.com.au';
    $yourEmail 'admin@precisionhomes.com.au';
    $yourSubject 'Contact Form';
    $referringPage 'http://www.precisionhomes.com.au';
    // No need to edit below unless you really want to. It's using a simple php mail() function. Use your own if you want
    function cleanPosUrl ($str) {
    return 
    stripslashes($str);
    }
        if ( isset(
    $_POST['sendContactEmail']) )
        {
        
    $to $yourEmail;
        
    $subject $yourSubject.': '.$_POST['posRegard'];
        
    $message cleanPosUrl($_POST['posText']);
        
    $headers "From: ".cleanPosUrl($_POST['posName'])." <".$_POST['posEmail'].">\r\n";
        
    $headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
        
    $mailit mail($to,$subject,$message,$headers);
            if ( @
    $mailit ) {
            
    header('Location: '.$referringPage.'?success=true');
            }
            else {
            
    header('Location: '.$referringPage.'?error=true');
            }
        }
    ?>

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    What isn't it doing? Which part of the script is not doing what you want?

    If it's not printing the main message it might be because you have:
    $mail->Body in the script but arent then using it anywhere.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

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