Results 1 to 2 of 2

Thread: can submit a form through e-mail

  1. #1
    Join Date
    May 2010
    Posts
    34
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Angry can submit a form through e-mail

    Hi all,
    I want to know how the submit a form via e-mail. I tried some code but I failed.
    this is code that I have tried,
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <form name="form_info" method="post" action="send_mail.php">
      <div>
    <table>
          <tr> 
            	<td> Your Email</td>
          </tr>
          <tr> 
            	<td ><input type="text" name="from" value="email"></td>
          </tr>
    	     
            	<td>Subject</td>
          </tr>
          <tr> 
            	<td ><input type="text" name="subject" value="subject"></td>
          </tr>
    	  <tr> 
            	<td> Message</td>
          </tr>
    	  <tr> 
            	<td><textarea name="message"></textarea></td>
    	  </tr>
          <tr> 
        </table>
        <table >
          <tr> 
            	<td> <input type="submit" name="Email" value="Email"></td>
          </tr>
        </table>
        <input type="hidden" name="to" value="hadunprera@yahoo.com">
      </div>
    </form>
    </body>
    </html>
    and send_mail.php,
    Code:
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    
    <?php
    
    $from = $_POST['from'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $to = $_POST['to'];
    
    $to="$to";
    $headers.= "MIME-Version: 1.0\r\n";
    $headers.= "Content-type: text/html; ";
    $headers.= "charset=iso-8859-1\r\n";
    
    $headers.= "From: $from";
    
    $subject = "$subject";
    $body = "$message";
    
    $send_check=mail($to,$subject,$body,$headers);
    if ($send_check!=true) {die();}
    ?>
    
    <table align="center" >
      <tr > 
        <td> 
          <div align="center">YOUR MESSAGE HAVE BEEN SENT
        </td>
      </tr>
    </table>
    </body>
    </html>
    then I was upload this code. http://www.haduntest.comli.com/

    But it is not working.
    When I click one the send button it shows the next page which display "YOUR MESSAGE HAVE BEEN SENT".

    But no mail has received to my mail account.

    can you tell me what is error with this code ???

  2. #2
    Join Date
    Nov 2008
    Posts
    58
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default

    The reason can be the 'from' field See the link below
    Why is my PHP script not sending emails

    Also see
    PHP Form to email explained

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
  •