2016-04-15 21 views
0

Ich verwende Dreamweaver, um eine einfache, in Kürze erscheinende Website zu erstellen. Wenn ich jedoch auf die Schaltfläche "Senden" in meinem Formular klicke, öffnet es einfach meine Standard-Mail-Anwendung und fordert mich auf, die E-Mail zu senden. Ich habe dann ein PHP erstellt, das die E-Mail senden soll. Wenn jemand es sehen könnte, würde ich sehr geschätzt werden. Wenn Sie den PHP reparieren, können Sie mir die ganze Version geben, ich bin nicht sehr gut in diesem Zeug und verstehe das meiste nicht.Senden Sie eine E-Mail, wenn ein Formular gesendet wird

<!doctype html> 
<html lang="en-US"> 
<head> 
<meta charset="UTF-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<title>Fiction Filming</title> 
<link rel="shortcut icon" href="images/favicon3.ico" type="image/x-icon" /> 
<style type="text/css"> 
body { 
    background-color: #2c2c2c; 
} 
</style> 
<link href="Css/singlePageTemplate.css" rel="stylesheet" type="text/css"> 
<!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.--> 
<script>var __adobewebfontsappname__="dreamweaver"</script> 
<script src="http://use.edgefonts.net/source-sans-pro:n2:default.js" type="text/javascript"></script> 
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
<!--[if lt IE 9]> 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <![endif]--> 
</head> 
<body> 
<!-- Main Container --> 
<div class="container"> 
    <!-- Navigation --> 
    <!-- Hero Section --> 
    <!-- About Section --> 
    <!-- Stats Gallery Section --> 
    <div class="gallery"><img src="Images/Newbannercomingsoon.png" alt="" width="1000" height="500" class="logo-pic"/> </div> 
    <!-- Parallax Section --> 
    <!-- More Info Section --> 
    <!-- Footer Section --> 
    <section class="footer_banner" id="contact"> 

<form class="subscribeForm form-fix" name="Subscription Form" method="post" action="mailform.php"> 
      <div class="newform"> 
       <div> </div> 
       <div> 
       <input id="fname" type="text" placeholder="NAME" name="name" required> 
       </div> 
       <div> 
       <input name="email" type="email" required id="email" placeholder="EMAIL"> 
       </div> 
       <div> 
       <select name="select" required id="myselect"> 
        <option>HELP/SUPPORT</option> 
        <option>BUSINESS ENQUIRES</option> 
        <option>OTHER</option> 
       </select> 
       </div> 
       <div class="text-form"> 
       <div> 
        <textarea name="textarea" required id="textarea" placeholder="TYPE YOUR TEXT HERE"></textarea> 
       </div> 
       </div> 
       <br><input name="Send" type="submit" id="Send" value="Send"> 
</div> 
</form> 
<!-- Step 1: Add an email field here --> 

<!-- Step 2: Add an address field here --> 
      <!-- Step 3: add a submit button here --> 

</section> 
    <!-- Copyrights Section --> 
<div class="copyright">&copy;2016 - <strong>Fiction filming</strong></div> 
</div> 
<!-- Main Container Ends --> 
</body> 
</html> 

Und hier ist die PHP

<!doctype html> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset="UTF-8"> 
<META HTTP-EQUIV="refresh" content="3;URL=thankyou.html"> 
<title>Email Form</title> 
</head> 

<body> 
<?php 
if(isset($_POST['submit'])){ 

// Or the below if using "name="Send" for the input. Uncomment and get rid of the above 
// if(isset($_POST['Send'])){ 
    $to = "[email protected]"; 
    $from = $_POST['email']; 
    $sender_name = $_POST['name']; 
    $subject = $_POST['select']; 
    $textarea = $_POST['textarea']; 
    $body = $sender_name . " wrote the following:" . "\n\n" . $textarea; 
    $subject = $subject; 
    mail($to,$subject,$body); 

    if(mail($to,$subject,$body)){ 
    echo "Mail was sent. Check both your inbox and spam, as mail as done its job."; 
} 
else{ 
    echo "There was a problem. Check your logs."; 
} 
    } 

    // $headers = "From:" . $from; 
    // $headers2 = "From:" . $to; 
    //echo "Mail Sent. Thank you " . $name . ", we will contact you shortly."; 
    // You can also use header('Location: thank_you.php'); to redirect to another page. 
    //} 
?> 
</body> 
</html> 
+0

Nicholas, zunächst einmal zertifizieren Sie sich, dass beide Dateien im selben Ordner befinden. 2) Die Dateien müssen sich auf einer Website befinden, dh auf einer Maschine von einem ISP gehostet, unter einer öffentlichen IP und mit einem sendmail-Dienst eingerichtet sein. 3) ändere die Zeile '
' an ​​'
' – statosdotcom

+0

Ok. Alle Dateien befinden sich im selben Ordner auf einer Website mit dem Befehl mail. Ich habe versucht, die Zeile, die Sie gesagt haben, zu ändern, ich werde Ihnen sagen, ob es funktioniert –

+0

Es ist interessant, denn hier scheint es alles funktioniert. – statosdotcom

Antwort

0

Nikolaus, sich zunächst einmal bestätigen, dass beide Dateien im selben Ordner befinden. 2) Die Dateien müssen sich auf einer Website befinden, dh auf einer Maschine von einem ISP gehostet, unter einer öffentlichen IP und mit einem sendmail-Dienst eingerichtet sein. 3) ändern Sie die Zeile

<br><input name="Send" type="submit" id="Send" value="Send">

zu

<br><input name="submit" type="submit" id="submit" value="Send">

+0

Vielen Dank Nicholas. Plus 1 du. – statosdotcom

Verwandte Themen