Current location: Hot Scripts Forums » Programming Languages » PHP » php email problem


php email problem

Reply
  #1 (permalink)  
Old 11-06-08, 05:16 AM
sujata_ghosh sujata_ghosh is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
php email problem

hi to all!

I have made a html contact form and the following php code to get those form data and send them via email to me. but the problem is everytime i am getting 2 emails, 1 is blank with all fields and 1 is with complete form data entered by the visitors. can anyone tell me why is this happening?


here is html form coding:


Code:
<form name="form1" action="contact.php" method="post" enctype="multipart/form-data">
            &nbsp;<small>Enter your Name</small>: <BR>
   <INPUT size="30" name="name"> 
   <br>
   <BR>
   &nbsp;<small>E-mail address</small>: <BR>
   <INPUT maxLength="100" size="30" name="email"> 
   <br>
   <BR>
   &nbsp;<small>Message Subject</small>: <BR>
   <INPUT size="30" name="subject"> 
   <br>
   <br>
   &nbsp;<small>Enter your Message</small>: <BR>
   <TEXTAREA name="comments" rows="10" cols="50"></TEXTAREA> 
    <BR><BR>        
   
            <input type="button" name="btn" value="Submit" onclick="javascript:validateform()" />&nbsp;
   <input type="reset" name="Reset" value="Reset" /> 
        </form>


----------------------------------------------------------------------------------------------


here is full php coding:

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>
<title>Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<base href="http://www.onlinedoctoraldegrees.org/" />
<meta name="robots" content="index, follow" />
<meta name="title" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/formval.js"></script>
</head>
<body>
<div id="container">
 <div class="containerbrd">
  <div id="header">
    <?php include("ssi/header.html");  ?>
   <br style="clear:both" />
   </div> 
       <?php include("ssi/banner.html");  ?>

  <div id="content">
   <div id="leftcontent">
         <?php include("ssi/leftmenu.html");  ?></div>
   <div id="centercontent">
<div align="left"></div>
   <h1 align="left" class="pageheading">Contact Us</h1><br />

 <?php
 $path = $_SERVER['SERVER_NAME'];
    $Name = $_POST["name"];
 $Email = $_POST["email"];
 $Subject = $_POST["subject"];
 $Comments = $_POST["comments"];
 
$mailto = "webmaster@onlinedoctoraldegrees.org";
$subject = "Web-Query - ".$Subject;
$header = "From: $Email\n";
$header = $header."Return-Path: webmaster@onlinedoctoraldegrees.org\n";
$header = $header."Reply-to: $Email\n";
$header = $header."MIME-Version: 1.0\n";
$header = $header."Content-Type: text/plain; charset=iso-8859-1\n";
$header = $header."Content-Transfer-Encoding: 8bit\n";
$header = $header."X-Priority: 1\n";
$header = $header."X-MSMail-Priority: High\n";
$header = $header."Importance: High\n";
$header = $header."X-Mailer: PHP\n";
$header = $header."X-MimeOLE: Produced By php\n";

$body =       "Web-Query - ".$Subject."\n";
$body = $body."-----------------------------------------------------\n";
$body = $body."Name     : ".$Name."\n\n";
$body = $body."Email    : ".$Email."\n\n";
$body = $body."Subject   : ".$Subject."\n\n";
$body = $body."Commnets : \n".$Comments."\n";

if(mail($mailto,$subject,$body,$header)) 
{
 echo "<h5 style=\"color:#5A4C39;\">Thank you for contacting us. We will get back to you shortly. <br><a href=\"<A href="http://".$path."\">Back</a></h5">http://".$path."\">Back</a></h5>";
}
else 
{
  echo "Mail could not be sent!";
exit;
}
 
?>
            <p align="justify">&nbsp;</p>
            <p align="justify">&nbsp;</p>
            <p align="justify">&nbsp;</p>
            <p align="justify">&nbsp;</p>
            <p align="justify">&nbsp;</p>
            <p align="justify">&nbsp;</p>
   <p align="justify">&nbsp;</p>
   <p align="justify">&nbsp;</p>
   </div>
    <div id="rightcontent">
   <?php include("ssi/rightadv.html");  ?>
   </div>
   <br style="clear:both" />
  </div>
  
  <div id="footer">  
       <?php include("ssi/footer.html");  ?>
  </div>
 </div>
</div>
</body>
</html>
thanks!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with CSS and PHP working together:( cssgopher PHP 7 03-24-08 03:31 AM
file attachment problem on email script sujata_ghosh Perl 2 01-11-07 01:17 AM
Urgent problem with PHP domxml_open_mem(), php extension php_domxml.dll. Need help! Oskare100 Web Servers 3 01-03-07 05:08 AM
can you use php to get someone's email address from a mailer? pagetta PHP 8 11-11-05 05:36 AM
Help php email with xls attachment dhimo PHP 0 10-19-05 04:59 AM


All times are GMT -5. The time now is 08:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.