2017-05-29 4 views
0

現在、HTMLの連絡フォームまたはphp mail()関数を使用してその内容を送信しようとしています。ただ電話を切って助けを求めてください。htmlの連絡フォームを使用してphpメールを送信するにはどうすればいいですか?

入力したテキストと、PHP経由で連絡先フォームに指定された電子メールアドレス

だから、私だけが私のデータが入力された方法を知っていると...

HTMLコードでそれを送信しないでください...私のコードは、現在見て、それが動作します:

  <form class="" action="senden.php" method="post"> 
 
      <div class=""> 
 
       <label>Name</label> 
 
       <input type="text" name="von" placeholder="Bitte geben Sie Ihren Namen ein" value=""> 
 
       <label>E-Mail Adresse</label> 
 
       <input type="text" name="email" placeholder="Bitte geben Sie Ihre Email-Adresse ein" value=""> 
 
       <label>Telefonnummer</label> 
 
       <input type="tel" name="tel" placeholder="Bitte geben Sie Ihre Telefonnummer ein" value=""> 
 
      </div> 
 
      <div class=""> 
 
       <label>Nachricht</label> 
 
       <textarea placeholder="Bitte geben Sie Ihre Nachricht ein" name="nachricht" rows="8" cols="40"></textarea> 
 
       <button type="submit" name="submit" value="">Nachricht Abschicken</button> 
 
      </div> 
 

 
      </form>

`

PHPコード:

<?php 
 
      $empfaenger = "[email protected]"; 
 
      $betreff = "Mail Function"; 
 
      $from = "From: Max Reimers <[email protected]>"; 
 
      $text = "Email Email Email Email Text Text Text"; 
 

 
      mail($empfaenger, $betreff, $text, $from); 
 
?>

+0

の可能性のある重複(https://stackoverflow.com/questions/5335273/how [PHPを使用して電子メールを送信する方法は?]メールを使用して電子メールを送信する) – Qirel

+0

https://stackoverflow.com/questions/13232631/get-all-post-data-and-send-in-emailの重複 –

+2

[Unable to php mail()経由でメールを送信する](https://stackoverflow.com/questions/4733154/unable-to-send-mail-via) -php-mail) –

答えて

1

ここではコードです:

<form class="form-horizontal" action="" id="contact-form" method="post"> 
 
        <fieldset> 
 
         <legend class="text-center colheader">Email Us</legend> 
 
         <div class="form-group"> 
 
          <div class="col-md-10 col-md-offset-1"> 
 
           <input id="name" name="name" type="text" placeholder="Full Name" class="form-control" required> 
 
          </div> 
 
         </div> 
 
         
 

 
         <div class="form-group"> 
 
          <div class="col-md-10 col-md-offset-1"> 
 
           <input id="email" name="email" type="text" placeholder="Email Address" class="form-control" required> 
 
          </div> 
 
         </div> 
 

 
         <div class="form-group"> 
 
          <div class="col-md-10 col-md-offset-1"> 
 
           <input id="phone" name="phonenumber" type="text" placeholder="Phone" class="form-control" required> 
 
          </div> 
 
         </div> 
 
        <div class="form-group"> 
 
          <div class="col-md-10 col-md-offset-1"> 
 
           <input id="subject" name="subject" type="text" placeholder="Subject" class="form-control"> 
 
          </div> 
 
         </div> 
 
         
 
         <div class="form-group"> 
 
          <div class="col-md-10 col-md-offset-1"> 
 
           <textarea class="form-control" id="message" name="messag" placeholder="Enter your massage for us here. We will get back to you within 2 business days." rows="7" required></textarea> 
 
          </div> 
 
         </div> 
 

 
         <div class="form-group"> 
 
          <div class="col-md-12 text-center"> 
 
           <button type="submit" name="submit" class="btn btn-primary btn-lg">Submit</button> 
 
          </div> 
 
         </div> 
 
        </fieldset> 
 
       </form> 
 
<?php 
 
if(isset($_POST['submit'])) { 
 
    
 
    $to = '[email protected]'; 
 
    $from = $_POST['email']; 
 
    $subject ='Adlivetech Contact Form'; 
 
    $name = $_POST['name']; 
 
    $email = $_POST['email']; 
 
    $phone = $_POST['phonenumber']; 
 
    $subject = $_POST['subject']; 
 
    $messag = $_POST['messag']; 
 
    
 

 
$message = '<html><body>'; 
 

 
$message .='<table>'; 
 
$message .='<tr><td>Name:</td><td>'. $name .'</td></tr>'; 
 

 
$message .='<tr><td>Email:</td><td>'. $email .'</td></tr>'; 
 

 
$message .='<tr><td>Phone:</td><td>'. $phone .'</td></tr>'; 
 

 
$message .='<tr><td>Subject:</td><td>'. $subject .'</td></tr>'; 
 

 
$message .='<tr><td>Message:</td><td>'. $messag .'</td></tr>'; 
 

 
$message .='</table>'; 
 

 
$message .='</body></html>'; 
 

 

 
$headers = "MIME-Version: 1.0" . "\r\n"; 
 
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
 
$headers .= "To: {$to}\r\n"; 
 
$headers .= "From: {$name} <{$from}>\r\n"; 
 
$headers .= "Reply-To: <{$to}>\r\n"; 
 
$headers .= "Subject: {$subject}\r\n"; 
 
$headers .= "X-Mailer: PHP/".phpversion()."\r\n"; 
 

 
mail($from, $subject, $message, $headers); 
 
    
 
} 
 

 
?>

関連する問題