PHP Form Email Help, Joomla

Discussion in 'PHP' started by Tinkleheimer, Sep 24, 2009.

  1. #1
    Hi there, I am attempting to make a form that emails me the results. I used the following tutorial video:

    http://www.youtube.com/watch?v=rdsz9Ie6h7I

    I read somewhere that the variables he put in at 13:13 were wrong, so I just assumed they were supposed to be the variables that I named recently.

    Here is the HTML Form Code I have on Joomla:
    <form action="http://qualityposting.net/contactformprocess.php" method="post">
    <strong>Name:</strong><br /> 
    <input name="name" size="50" type="text" /> <br /> 
    <strong>Email:</strong><br /> 
    <input name="email" size="50" type="text" /> <br /> 
    <strong>Paypal Email:</strong><br /> <input name="paypal" size="50" type="text" /> <br /> 
    <strong>Forum URL:</strong><br /> <input name="forum" size="50" type="text" /><br /> 
    <strong>Package:</strong><br /> 
    <select> 
    <option value="trial">Trial Package 10 Posts $3.00</option> 
    <option value="trialplus">Trial Plus 25 Posts $7.50</option> 
    <option value="basic">Basic 50 Posts $14.00</option> 
    <option value="basicplus">Basic Plus 150 Posts $40.00</option> 
    </select><br /> 
    <strong>Special Instructions:</strong><br /> <textarea cols="50" rows="15" name="instructions">
    Input any special instructions you may have for this job, including past names or new names 
    (if returning client), if you would like a different amount 
    of threads/replies, or if you want this completed sooner or farther away than normal.
     Remove this text before writing special instructions. 
    </textarea> <br /><br /> <input type="submit" value="Send" /> </form>
    HTML:
    And here is the Action PHP that should be executing:

    <?php
    
    // Subject and Email Variables
    
    	$emailSubject = 'New Job Inquiry From Quality Posting';
    	$webMaster = 'mastert2628@vfemail.net';
    	
    // Gathering Data Variables
    	
    	$nameField = $_POST['name'];
    	$emailField = $_POST['email'];
    	$paypalField = $_POST['paypal'];
    	$forumField = $_POST['forum'];
    	$trialField = $_POST['trial'];
    	$trialplusField = $_POST['trialplus'];
    	$basicField = $_POST['basic'];
    	$basicplusField = $_POST['basicplus'];
    	$instructionsField = $_POST['instructions'];
    	
    	$body = <<<EOD
    <br><hr><br>
    Name: $nameField <br>
    Email: $emailField <br>
    Paypal Email: $paypalField <br>
    Forum Link: $forumField <br>
    Package: $trialField $trialplusField $basicField $basicplusField <br>
    Special Instructions: $instructionsField <br>
    EOD;
    
    	$headers = "From: $emailField\r\n";
    	$headers .= "Content-type: text/html\r\n";
    	$success = mail($webMaster, $emailSubject, $body, $headers);
    	
    // Results Rendered As HTML
    
    	$theResults = <<<EOD
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <p>Congrats, your order is being processed. We will get a hold of you within 24-48 hours to confirm your order.</p>
    </body>
    </html>
    EOD;
    
    echo "$theResults" ;
    	
    ?>
    PHP:
    This is a link to the contact form as shown on my Joomla website:
    http://qualityposting.net/index.php?option=com_content&view=article&id=2&Itemid=3

    I would put in all required information into form, and then hit send. It takes me to the confirmation screen. However I do not get any email with the form results. Am I missing something important? I am completely new to PHP, again. And feel I have learned so much so fast. If anyone could kindly tell me what I did wrong, it would be greatly appreciated! :)
     
    Last edited: Sep 24, 2009
    Tinkleheimer, Sep 24, 2009 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    Try this:
    update this line
    
    $headers = "From: $emailField\r\n";
    
    PHP:
    to
    
    $headers = "From: you@your-website.com\r\n";
    
    PHP:
    where your-website.com is the website where you run this script

    The following pages might be helpful:

    Email forms


    Form to email using PHP
     
    prasanthmj, Sep 24, 2009 IP
  3. Tinkleheimer

    Tinkleheimer Peon

    Messages:
    220
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you so much! That fixed it. It is working wonderfully right now. Thanks again!
     
    Tinkleheimer, Sep 24, 2009 IP