2016-06-27 6 views
-2

Bitte kann ich Ihre Hilfe haben? Ich habe eine einfache HTML-Tabelle mit Texteingabefeldern für das Geschäft meiner Mutter erstellt, ich möchte sie in einer E-Mail senden, also habe ich ein PHP-Skript erstellt, aber es sendet niemals die E-Mail. Ich habe viele einfache Formen auf meinem Server, die gut funktionieren, aber ich verwendete HTML-Formulare, so dass es sehr einfach war. Ich kann jedoch nicht herausfinden, was mit dem Code falsch läuft. Das PHP-Skript wird ausgelöst und ich bekomme eine Bestätigungsnachricht und umgeleitet zu meinem Menü, aber keine E-Mail. Ich habe meinen Code so vereinfacht, dass er nur eine Tabellenzeile, eine Dropdown-Box und zwei Texteingabefelder enthält. Könnte mir bitte jemand die Lösung zu meinem Fehler zeigen? Ich habe Grundkenntnisse in PHP.html Tabelle laden php Datei onclick und senden Werte

Dies ist der Link zu meiner Website "seine grundlegende" Form, mit der ich festhalte, ist die Miete Form, der Rest funktioniert gut. http://www.edwinswebsite.co.uk/index.html

<!DOCTYPE html> 

<!-- 
    edwin martin 
    27/06/2016 
    V1 
--> 
<html lang="en"> 
    <head> 
    <!-- ensures the document is using the correct char set --> 
    <meta charset="utf-8"> 
    <meta name="description" content="a quick description of the page goes here"> 

    <title>payment form</title> 
    <link rel="stylesheet" href="styles/style.css"> 

<!-- 
     The below section looks like a comment, but it's a conditional include statement. 
     It's ignored by all browsers except IE9. html5shiv is a library that fixes some HTML5 
     IE bugs. 
--> 

    <!--[if lt IE 9]> 
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 
    <![endif]--> 
    <style type="text/css"> 


    </style> 
    </head> 

    <body> 
    <div id="wrapper"> 
      <h1 class="red">Proof of Payment Form</h1> 

      <table> 
      <caption> 
      <select size="1" name="cf_drop_down" class="drop"> 
       <option value=" Not selected">Select Address</option> 
       <option value=" 2 Some rd">2 Some rd</option> 
       <option value=" 6 Other rd">6 Other rd</option> 
       <option value=" 7 More rd">7 More rd</option> 
       <option value=" 19 More rd">19 More rd</option> 
       <option value=" 38 More rd">38 More rd</option> 
       <option value=" 54 Forth rd">54 Forth rd</option> 
       <option value=" 72 Fifth ave">72 Fifth ave</option> 
       <option value=" 77 Fifth ave">77 Fifth ave</option> 
       <option value=" 99 Fifth ave">99 Fifth ave</option> 
      </select> 
      </caption> 
      <tr> 
       <th> Student 1 Name</th> 
       <th> Student 2 Name </th> 
       <th> Student 3 Name </th> 
       <th> Student 4 Name </th> 
       <th> Student 5 Name </th> 
       <th> Student 6 Name </th> 
       <th> Student 7 Name </th> 

      </tr> 

      <tr> 
       <td><input type="text" value="test" name="cf_name1"></td> 
       <td><input type="text" value="test" name="cf_name2"></td>    
       <td><input type="text" value=""></td> 
       <td><input type="text" value=""></td> 
       <td><input type="text" value=""></td> 
       <td><input type="text" value=""></td>    
       <td><input type="text" value=""></td> 
      </tr> 


<input type="button" value="Send" class="submit_button" onclick="location.href='payment.php'" method="post"> 
<input type="button" value="Menu" class="submit_button" onclick="location.href='index.html'">   
     </table> 

     </div> 
    </body> 
</html> 

PHP-Code

<?php 
$field_name = $_POST['cf_name1']; 
$field_name2 = $_POST['cf_name2']; 


$drop_down_item = $_POST['cf_drop_down']; 


$mail_to = '[email protected], [email protected]'; 
$subject = 'Message from me '.$field_name; 


$body_message = 'From: '.$field_name."\n"; 
$body_message .= 'E-mail: '.$field_name2."\n"; 
$body_message .= 'Address: '.$drop_down_item."\n"; 


$headers = 'From: '.$field_name."\r\n"; 


$mail_status = mail($mail_to, $subject, $body_message, $headers); 

if ($mail_status) { ?> 
    <script language="javascript" type="text/javascript"> 
     alert('Thank you for the message. We will contact you shortly.'); 
     window.location = 'index.html'; 
    </script> 
<?php 
} 
else { ?> 
    <script language="javascript" type="text/javascript"> 
     alert('Message failed. Please, send an email to [email protected]'); 
     window.location = 'index.html'; 
    </script> 
<?php 
} 
?> 
+0

hier keine Form gibt es Tags –

+0

Sie sollten auch alle diejenigen markieren Ihre Fragen wurden gelöst, wo Antworten gegeben wurden, die sie lösten. –

+0

nein, ich versuche herauszufinden, ob es möglich ist, ohne ein Formular, oder? – edwin

Antwort

0

Ok jetzt einfach i in der Tabelle ein Formular-Tag setzen und meine php funktioniert gut