Results 1 to 2 of 2

Thread: Form doesn't show completed fields in email

  1. #1
    Join Date
    Aug 2009
    Location
    London
    Posts
    93
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Default Form doesn't show completed fields in email

    Hi,

    I have adapted a form php script. I have just tested it and even though I filled all 3 fields out, the email I receive shows the first 2 as blank (FirstName & Surname).

    Please can someone help me correct this? Thanks in advance!

    PHP Code:
    <?php

    $EmailFrom 
    "The Website";
    $EmailTo "me@mydomain.com";
    $Subject "A Message From Your Website";
    $Name Trim(stripslashes($_POST['FirstName'])); 
    $Tel Trim(stripslashes($_POST['Surname'])); 
    $Email Trim(stripslashes($_POST['Email'])); 

    // validation
    $validationOK=true;
    if (!
    $validationOK) {
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }

    // prepare email body text
    $Body "";
    $Body .= "FirstName: ";
    $Body .= $FirstName;
    $Body .= "\n";
    $Body .= "Surname: ";
    $Body .= $Surname;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";

    // send email 
    $success mail($EmailTo$Subject$Body"From: <$EmailFrom>");

    // redirect to success page 
    if ($success){
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>
    HTML Code:
    <form method="post" action="contactengine.php">
    <label for="Name"> * First Name:</label>
    <input type="text" name="FirstName" id="FirstName" />
    				
    <label for="City"> * Surname:</label>
    <input type="text" name="Surname" id="Surname" />
    	
    <label for="Email"> * Email:</label>
    <input type="text" name="Email" id="Email" />
    				
    
    <input type="submit" name="submit" value="Submit" class="submit-button" />
    </form>

  2. #2
    Join Date
    Aug 2009
    Location
    London
    Posts
    93
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Default

    I just worked it out myself - couldn't see the wood for the trees!

Similar Threads

  1. Required fields in php email form
    By xur82 in forum PHP
    Replies: 1
    Last Post: 05-29-2012, 02:45 PM
  2. PHP Form Fields Show up Empty?
    By shelliezdesign in forum PHP
    Replies: 1
    Last Post: 09-23-2009, 06:40 AM
  3. Replies: 0
    Last Post: 08-22-2008, 12:44 AM
  4. Centred page after form is completed
    By tacbob in forum HTML
    Replies: 4
    Last Post: 11-29-2004, 11:34 AM
  5. Centred page after form is completed?
    By tacbob in forum JavaScript
    Replies: 2
    Last Post: 11-29-2004, 07:53 AM

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
  •