Kontaktformular für Webseite

Berlin 222

Grünschnabel
Ich habe folgendes Kontaktformular erstellt. Möchte jedoch die Felder Firma und E-Mail zu Pflichtfeldern machen. Habe schon ewig dran gebastelt, bekomme aber immer nur Fehlermeldungen, da ich selbst kein PHP kann :-(
Vielleicht kann mir jemand helfen? Das wäre supi...
Code:
<html>

<head>
<meta http-equiv="Content-Language" content="de">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script type="text/javascript" language="JavaScript">


function printPage() {
if (window.print) {
jetztdrucken = confirm('Print ?');
if (jetztdrucken) window.print();
   }
}


</script>
<base target="_top"><base target="_top">
</head>

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin="10">

<div align="center">
	<table border="0" cellpadding="0" cellspacing="0" width="800" height="600">
		<!-- MSTableType="layout" -->
		<tr>
			<td valign="top" width="363" height="38">
			<!-- MSCellType="ContentHead" -->
			<a name="zurueck">
			<b><font color="#5F5F5F" face="Verdana">
			<span style="text-decoration: none; font-size: 9pt">
		<img border="0" src="../bilder_test/Logo.gif" width="342" height="56"></span></font></b></a></td>
			<td valign="top" width="362" height="38">
			<!-- MSCellType="ContentHead" -->
			<b><font color="#5F5F5F" face="Verdana">
			<span style="font-size: 9pt">&nbsp;|</span><span style="text-decoration: none; font-size: 9pt"><font style="font-size: 9pt; text-decoration:none"><a href="../start_english.html"><font color="#5F5F5F"><span style="text-decoration: none">Home</span></font></a></font><font style="font-size: 9pt; "><span style="font-size: 9pt">| 
			|</span></font><font style="font-size: 9pt; text-decoration:none"><a href="sitemap_english.html"><font color="#5F5F5F"><span style="text-decoration: none">Sitemap</span></font></a><span style="font-size: 9pt"><font style="font-size: 9pt; ">|</font></span></font></span></font><font color="#5F5F5F" face="Verdana" style="font-size: 9pt; "> <span style="font-size:9pt">|</span><span style="text-decoration: none"><a href="javascript:printPage()"><span style="text-decoration: none; font-size:9pt"><font color="#5F5F5F">Print</font></span></a></span><span style="font-size:9pt"> 
			|</span>&nbsp; 
			|</font><font color="#5F5F5F" face="Verdana" style="font-size: 9pt; text-decoration:none"><a href="../sz61f.html"><span style="text-decoration: none"><font color="#5F5F5F">German</font></span><font color="#5F5F5F"><span style="text-decoration: none; font-size:9pt">|</span></font></a>|<a target="_blank" href="../downloadbereich/test_Programm_Bahn_RUS.pdf"><span style="text-decoration: none; font-size:9pt"><font color="#5F5F5F">??????? 
			????</font></span></a>|</font><font color="#5F5F5F" face="Verdana" style="font-size: 9pt"><form>
                        
</form></font></b></td>
		</tr>
		<tr>
			<td valign="top" height="37" colspan="2">
			<!-- MSCellType="ContentHead" -->
			<b><font face="Verdana" size="2">&nbsp;intelligent motivated 
			engineers</font></b><hr color="#C0C0C0" size="1">



		


			
					
					
					
					
					
					
      					</td>
		</tr>
		<tr>
			<td valign="top" width="725" height="425" colspan="2">
			<!-- MSCellType="NavBody" -->
			<table border="0" width="116%" id="table1">
			<!-- MSTableType="nolayout" -->
			<tr>
				<td width="100%">
				<p align="left"><b><font face="Verdana" size="2">Contact</font></b></td>
				</tr>
			<tr>
				<td width="100%">
				<hr color="#CC3333" size="1" align="right"></td>
				</tr>
			<tr>
				<td width="99%" valign="top">
				<p align=left style="line-height:1pc; margin-top:0pc; margin-bottom:1pt;">
		<font face="Verdana" size="2">You can get in touch with us during our 
		 on <br>
		 by Phone: +49 30 <br>
		 Fax.: +49 30 3</font></p>
				<p align="left" style="line-height:1pc; margin-top:0pc; margin-bottom:1pt;">

<form method="post" action="<?$PHP_SELF?>">

<div align="center">
<table border="0" width="100%" id="table2">
						
<tr bgcolor=#C0C0C0>
	<td width="34%"><font face="Verdana" size="2">Last Name:</font></td>
	<td width="214"><b><font face="Verdana" size="2"><input name="Nachname"></font></b></td>
	<td width="10%"><font face="Verdana" size="2">First Name:</font></td>
	<td width="168"><b><font face="Verdana" size="2"><input name="Vorname"></font></b></td>
</tr>

<tr>
	<td width="244" bgcolor="gainsboro">
	<font face="Verdana" size="2" color="#000080">*Company:</font></td>
	<td width="214" bgcolor="gainsboro"><b>
	<font color="#000080" face="Verdana" size="2">
	<input name="Firma"></font></b></td>
	<td width="70" bgcolor="gainsboro">
	<font face="Verdana" size="2" color="#000080">*e-mail:</font></td>
	<td width="168" bgcolor="gainsboro"><b><font face="Verdana" size="2">
	<input name="email"></font></b></td>
</tr>

<tr bgcolor=#C0C0C0>
	<td width="244"><font face="Verdana" size="2">Phone:</font></td>
	<td width="214"><b><font face="Verdana" size="2"><input name="Telefon"></font></b></td>
	<td width="70"><font face="Verdana" size="2">Fax:</font></td>
	<td width="168"><b><font face="Verdana" size="2"><input name="Fax"></font></b></td>
</tr>

<tr>
	<td width="244" bgcolor="gainsboro"><font face="Verdana" size="2">Subject:</font></td>
	<td colspan=3 width="464" bgcolor="gainsboro"><b>
	<font face="Verdana" size="2"><select name="Auswahl" size="1">
	<option selected value="general question">general question</option>
	<option value="inquiry">Inquiry</option>
	<option value="order">Order</option>
	<option value="request for documents">Documents</option>
	<option value="ideas/iriticism">Ideas/Criticism</option>
	<option value="request for call back ">Please call back</option></select></font></td>
</tr>

<tr bgcolor=#C0C0C0>
	<td width="244"><font face="Verdana" size="2">Textarea:</font></td>
	<td colspan=3 width="464"><font face="Verdana" size="2"><b><textarea rows="6" name="Bemerkungen" cols="57"></textarea></b></font></font></td>
</tr>

<tr>
	<td colspan=4 height=20 width="714" bgcolor="white"><b>
	<font face="Verdana" size="2">or just send us an e-mail:<font color="#0000FF">
	</font>
	<a href="mailto:test@testberlin.de"><font color="#0000FF">test@testberlin.de</font></a>.</font></b><font face="Arial"></p></font></td>
</tr>

<tr>
	<td colspan=4 align=center height=20 width="714" bgcolor="white"><font face="Arial">
	<input type=hidden name="machma" value="1" style="font-weight: 700"></font>
	<b><font face="Verdana" size="2">
	<input type=submit value="Send from" style="background-color: rgb(55,47,153); color: rgb(255,255,255); border: 1 ridge rgb(0,0,0); font-weight:700"></font></b><p align="left">
	<font color="#000080">
	<b><font face="Verdana" size="1">*) </font></b>
	<font face="Verdana" size="1">requested fields</font></font></td></form>
</td>
<!-- INHALT ENDE -->


<?

if ($machma == '1')
{

$body .= "Nachname      :".$Nachname."\n";
$body .= "Vorname       :".$Vorname."\n";
$body .= "Firma         :".$Firma."\n";
$body .= "Email         :".$email."\n";
$body .= "Telefon       :".$Telefon."\n";
$body .= "Fax           :".$Fax."\n";
$body .= "Grund         :".$Auswahl."\n\n";
$body .= "Text          :".$Bemerkungen."\n";


$headers = "FROM: $email\n";
$headers .= "Content-Type: text/plain\n";
mail("kontakt@test.de", "$Auswahl von der test Homepage", $body, $headers);

echo "<center><font size=2 color=#0000CC><b>Thank you. We´ve received your $Auswahl and get in touch with you as soon as possible</b><br><br>";

}

?>










</td>
						</tr>
					</table>
				</div>
				</td>
				</tr>
			<tr>
				<td><hr color="#CC3333" size="1">
				</td>
			</tr>
			</table>
			</td>
		</tr>
		<tr>
			<td valign="top" width="725" height="50" colspan="2">
			<!-- MSCellType="ContentFoot" -->
			<font face="Verdana" color="#5F5F5F" style="font-size: 9pt">
			<span style=""><b>|</b></span></font><b><a href="about_us.html"><font face="Verdana" style="font-size: 9pt; text-decoration: none" color="#5F5F5F">About 
			us</font></a><font face="Verdana" color="#5F5F5F" style="font-size: 9pt">| 
			<a href="get_in_touch.php">|<span style="text-decoration: none"><font color="#5F5F5F">|Get 
			in touch with test|</font></span>|</a>&nbsp; 
			|<span style="text-decoration: none"><a href="test_team.html"><font color="#5F5F5F"><span style="text-decoration: none">Your</span></font></a><font color="#5F5F5F"><a href="test_team.html"><span style="text-decoration: none"><font color="#5F5F5F"> test-Team</font></span></a></font></span>|&nbsp; |<span style="text-decoration: none"><font color="#5F5F5F"><a href="download_english.html"><font color="#5F5F5F"><span style="text-decoration: none">Downloads</span></font></a></font></span>|&nbsp; 
			|<span style="text-decoration: none"><a href="your_way_to_us.html"><font color="#5F5F5F"><span style="text-decoration: none">Your 
			way to us</span></font></a></span>|&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;
			<a href="../impressum.html"><font color="#5F5F5F">
			<span style="text-decoration: none"></span></font><font color="#5F5F5F">
			<span style="text-decoration: none"><a href="../impressum.html">
			<font color="#5F5F5F"><span style="text-decoration: none">|Privacy Policy|</span></font></a></span></font></font></b><p align="center">
			<a href="../sz61f.html"><font face="Verdana" size="2" color="#5F5F5F"><span style="text-decoration: none">test</span></font></a><font face="Verdana" color="#5F5F5F" size="2">®<a href="../sz61f.html"><span style="text-decoration: none"><font color="#5F5F5F"> 
          Berlin</font></span></a><span style="">&nbsp;</span></font></td>
		</tr>
	</table>
</div>


</body>

</html>

Danke schon mal für die Mühe des Lesens :)
 
PHP:
if (!$_POST['Firma'] || !$_POST['email'])
{
  //dein Code wenn die pflichtfelder nicht ausgefüllt wurden
}
else if ($_POST['machma'] == 1)
{
  //sie wurden ausgefüllt, mail wird hier versandt
}
 
Zuletzt bearbeitet:
Hallo Zodiak XP,

erst mal vielen vielen Dank für Deine Mühe.

Das das mit if und diesen Befehlen, wie von Dir beschrieben geht, habe ich auch schon probiert. Aber ich weiß nicht genau an welche Stellen des Quellcodes ich das einfügen muss. Ich kriege, wenn ich testen will immer eine PHP Fehlermeldung :-(

Parse error: syntax error, unexpected '}' in /home/vhosts..english/get_in_touch.php on line 159
 
Zuletzt bearbeitet:
Wenn du den Quelltext hier reinschreibs (zumindest die Zeilen in denen der Fehler ist) kann ich dir direkter helfen.

Aber so nochmal:

PHP:
if (!$_POST['Firma'] || !$_POST['email'])
{ ?>
  schreibe hier dein HTML-Code rein, der kommen soll wenn die Felder nicht ausgefüllt wurden
<?PHP }
else if ($_POST['machma'] == 1)
{ ?>
  schreibe hier dein HTML-Code rein, wenn sie ausgefüllt sind
<? PHP }

oder du machst es so:


PHP:
if (!$_POST['Firma'] || !$_POST['email'])
{
  readfile("die-html-wenn-die-felder-fehlen.html");
}
else if ($_POST['machma'] == 1)
{
    readfile("die-html-wenn-die-felder-ausgefüllt-worden.html");
}

etwas übersichtlicher ;)
 
Das das mit if und diesen Befehlen, wie von Dir beschrieben geht, habe ich auch schon probiert. Aber ich weiß nicht genau an welche Stellen des Quellcodes ich das einfügen muss. Ich kriege, wenn ich testen will immer eine PHP Fehlermeldung :-(

Parse error: syntax error, unexpected '}' in /home/vhosts..english/get_in_touch.php on line 159

Du hast es nicht modifiziert? Der Quelltext ist immernoch wie am Anfang?

Probiere bitte die von mir zuletzt genannte Variante.
Entweder per readfile(); (für HTML) oder per include(); (andere PHP)

Damit hast du den Code ein bisschen getrennt und die Fehlersuche wird einfacher.
 
Zurück