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
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Struggling to get the content from the html form through php script

    My html form is send me empty emails. Kindly help me with this. I'll be grateful to you all.

    My HTML Code:

    <!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>Biology Solutions</title>
    <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
    </head>
    <link rel="shortcut icon" href="http://www.biologysolutions.in/images/favicon.ico"/>
    <body>
    <h2>Contact form</h2>

    <form name="contactform" method="post" action="send_form_email.php">

    <div id="contact_form">

    <div class="form_row">
    <label>Name:</label>
    <input type="text" name="name" class="contact_input" />
    </div>

    <div class="form_row">
    <label>Email:</label>
    <input type="text" name="email" class="contact_input" />
    </div>

    <div class="form_row">
    <label>Phone:</label>
    <input type="text" name="phone" class="contact_input" />
    </div>

    <div class="form_row">
    <label>Message:</label>
    <textarea name="message" class="contact_textarea"></textarea>
    </div>

    <div class="send">
    <a href="http://www.biologysolutions.in/send_form_email.php">send</a>
    </div>

    </div>

    </form>

    </div><!--end of right content-->

    <div style=" clear:both;"></div>
    </div><!--end of main content-->


    <div id="footer">
    <div class="copyright">
    <a href="home.html"><img src="images/footer_logo.gif" border="0" alt="" title="" /></a>
    </div>
    <div class="footer_links">
    <a href="about.html">About us</a>
    <a href="privacy.html">Privacy policy</a>
    <a href="contact.html">Contact us </a>

    </div>
    </div>
    </div> <!--end of main container-->
    </body>
    </html>

    Here is my php Code:

    <?php

    /* Subject and Email Variables */

    $emailsubject = 'New Message';
    $webMaster = 'info@website.in'; /* Here I've given my email*/

    /* Gathering Data Variables */

    $nameField = $_POST['name'];
    $emailField = $_POST['email'];
    $phoneField = $_POST['phone'];
    $messageField = $_POST['message'];

    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Email: $email <br>
    Phone Number: $phone <br>
    Message: $message <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailsubject, $body, $headers);
    ?>

    Once again I'm requesting you all to help me. I've been struggling to get this right for the past three days and I'm frustrated. Desperate to get this done. Help me.

    Raghunath.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,339
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    This line:
    $success = mail($webMaster, $emailsubject, $body, $headers);

    What is the value of $success? - true or false?
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Tags for this Thread

    Posting Permissions

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