Form to E-Mail Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dink Creative
    New Member
    • Jul 2011
    • 3

    Form to E-Mail Problem

    Hi,

    I'm in the process of creating a form for the first time.

    All appears to be work until I click submit then instead of sending the e-mail it diects you to php script.

    I wonder if you coding geniuses could shed any light on this.

    my php code look as follows:
    Code:
    <?php
    $emailSubject = 'contactform';
    $webMaster = 'info@dinkcreative.co.uk';
    
    $email = $_POST['email'];
    $name = $_POST['name'];
    $comments = $_POST['comments'];
    
    
    
    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Email: $email <br>
    Comments: $comments <br>
    EOD;
    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body,
    $headers);
    
    /* Results rendered as HTML */
    $theResults = <<<EOD
    <html>
    <head>
    <title>sent message</title>
    <meta http-equiv="refresh" content="5;URL=http://www.dinkcreative.co.uk/contact.htm">
    <style type="text/css">
    <!--
    body {
    background-color:
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 20px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #000;;
    text-decoration: none;
    padding-top: 200px;
    margin-left: 150px;
    width: 800px;
    }
    -->
    </style>
    </head>
    <div align="center">Your message has been sent! We are now dealing with your request will get back to you asap</div>
    </div>
    </body>
    </html>
    EOD;
    echo "$theResults";
    ?>
    Last edited by Niheel; Jul 7 '11, 03:13 AM. Reason: code tags
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    The code you have posted does not contain a form

    Comment

    • Dink Creative
      New Member
      • Jul 2011
      • 3

      #3
      Hi, thank you for replying.

      I think the problem lies with the submission of the form, take a look at the attached form:

      Code:
      <form action="contactform.php" method="post" name="form1" id="contactform">
                  <label for="name">Name: <br/>
                  	<input type="text" name="name" id="name" />
                  </label><br/><br/>
                  
                  <label for="name">Email: <br/>
                    <input type="text" name="email" id="email" />
                  </label><br/><br/>
                  
                  <label for="name">Subject: <br/>
                  	<input type="text" name="subject" id="subject" />
                  	<br />
                  </label><br/>
                  
                  <label for="Comments">Comments:</label><br/>
                  <textarea name="Comments" cols="45" rows="5" id="Comments"></textarea><br/><br/>
                  <label>
                  <input name="Submit" type="submit" id="Submit" onclick="MM_validateForm('name','','R','email','','RisEmail','Comments','','R');return document.MM_returnValue" value="Submit" />
                  <label>
      </form>
      Last edited by Atli; Jul 8 '11, 08:34 PM. Reason: Added [code] tags.

      Comment

      • Dink Creative
        New Member
        • Jul 2011
        • 3

        #4
        any ideas folks? I'm puzzled by this and require your expert help!

        Comment

        • nathj
          Recognized Expert Contributor
          • May 2007
          • 937

          #5
          Hi,

          I've just read over the code and can see that when you call the mail function you provide a $body variable. this variable doesn't appear to be defined anywhere. Should it perhaps be $comments?

          hope this helps
          nathj

          Comment

          • ijenk
            New Member
            • Jul 2011
            • 1

            #6
            i've tried code like this, and i found error with port smtp email. if you run a code at localhost [not like http://yoursite.com] then code not will success. may be you can sent email use gmail account, but that just the first. coz gmail not allow to open smtp from simple action like you code. so u must run at http://yoursite.com and sent email from email@yoursite. com . this i guess.

            Comment

            Working...