html+php invulformulier

Status
Niet open voor verdere reacties.

suusje83

Nieuwe gebruiker
Lid geworden
23 dec 2006
Berichten
2
Hallo allemaal,
Ik maak een invulformulier waarvan de gegevens na een druk op de knop naar mn email verstuurd moeten worden...

Kan iemand mij vertellen wat er mis is aan deze code? Na een druk op de knop worden de gegevens niet verstuurd. Zonder php code start hij wel automatisch mijn email op.. Dit wil ik juist voorkomen met die formulier..

<?
if ($_POST[submit]) {

$tomail = "s.kamminga@gmail.com";
$frommail = $_POST[emailadres];
$fromname = $_POST[voornaam]." ".$_POST[achternaam];
$message = '
voornaam: '.$_POST[voornaam].'<br>
achternaam: '.$_POST[achternaam].'<br>
telefoonnummer: '.$_POST[telefoonnummer].'<br>
emailadres: '.$_POST[emailadres].'<br>
vragen: '.nl2br($_POST[vragen]).'<br>
';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$fromname."<".$frommail.">\r\n";
$headers .= "Return-Path: <".$frommail.">\r\n";

mail($tomail, 'Interesse', $message, $headers);
}
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Homegrown Tuintafel</title>
<style type="text/css">
<!--
.style17 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>

<style type="text/css">
<!--
body {
background-image: url(contact.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-repeat: no-repeat;
}

#formpje {
position: absolute;
top: 300px;
width: 390px;
height: 209px;
margin-left: 10px;
}

-->
</style>

<body text="#FFFFFF">

<div align="left">
<div id="formpje">

<table width="390" td height="209" align="left" cellpadding="0" cellspacing="0" text="#FFFFFF">

<tr>
<td width="128" height="28" align="left" valign="top" class="style14">
<div align="right"><font face="Arial, Helvetica, sans-serif, monospace"><strong><font color="#FFFFFF" size="2"><span class="style15"><span class="style17 style16">Voornaam</span>&nbsp;&nbsp;</font><font size="2">&nbsp;</font></strong></font></div></td>

<td width="262" height="28" align="left" valign="top"> <input name="voornaam" type="text" class="style1" size="40" width="262">
</td>
</tr>

<tr>
<td width="128" height="28" align="left" valign="top" class="style14"><div align="right"><font face="Arial, Helvetica, sans-serif, monospace"><strong><font size="2"><span class="style15"><span class="style16 style17"><font color="#FFFFFF">Achternaam</font>&nbsp;&nbsp;&nbsp;</span></span></font></strong></font></div></td>
<td height="28" align="left" valign="top"> <input name="achternaam" type="text" class="style1" id="achternaam" size="40" width="262">
</td>
</tr>

<tr>
<td width="128" height="28" align="left" valign="top" class="style14"><div align="right" class="style17"><font face="Arial, Helvetica, sans-serif, monospace"><strong><font color="#FFFFFF" size="2"><span class="style16">Telefoonnummer&nbsp;&nbsp;&nbsp;</span></font></strong></font></div></td>
<td height="28" align="left" valign="top"> <input name="telefoonnummer" type="text" class="style1" id="telefoonnummer" size="40" width="262">
</td>
</tr>

<tr>
<td width="128" align="left" valign="top" class="style14"><div align="right" class="style17"><font face="Arial, Helvetica, sans-serif, monospace"><strong><font color="#FFFFFF" size="2"><span class="style16">E-mailadres&nbsp;&nbsp;&nbsp;</span></font></strong></font></div></td>
<td height="28" align="left" valign="top"> <input name="emailadres" type="text" class="style1" id="emailadres" size="40" width="262">
</td>
</tr>

<tr>
<td width="128" height="44" align="left" valign="top" class="style14">&nbsp;</td>
<td height="44" align="left" valign="top">
<textarea name="vragen" cols="37" rows="3" id="vragen" height="44" widht="255" align="left" valign="top">Heeft u verder nog vragen?
Typt u die dan hier in.</textarea>
</td>
</tr>


<tr>
<td width="128" height="19" align="left" valign="top" td>&nbsp;</td>
<td align="left" valign="top">
<input type=submit value="Versturen">
<input type=reset value="Opnieuw">
</td>
</table>
</div>
</body>
</html>


Alvast hartstikke veel dank!
 
Hierbij een form welke werkt:
PHP:
<?
if ($_POST[submit]) {

$tomail = "vazed@zeelandnet.nl";"\r\n";
$frommail = $_POST[emailadres];"\r\n";
$fromname = $_POST[voornaam]." ".$_POST[achternaam];
$message = '
<br>
voornaam: '.$_POST[voornaam].'
<br>
achternaam: '.$_POST[achternaam].'
<br>
telefoonnummer: '.$_POST[telefoonnummer].'
<br>
emailadres: '.$_POST[emailadres].'
<br>
vragen: '.nl2br($_POST[vragen]).'
<br>
';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$fromname."\r\n";
$headers .= $frommail. "\r\n";
"\r\n";

mail($tomail, 'Interesse', $message, $headers);
}
?>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>
			Homegrown Tuintafel
		</title>
<style type="text/css">
<!--
.style17 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
	</head>
	
<style type="text/css">
<!--
body {
background-image: url(contact.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-repeat: no-repeat;
background-color:#c0c0c0;
}

#formpje {
position: absolute;
top: 300px;
width: 390px;
height: 209px;
margin-left: 10px;
}

-->
</style>
	
	<body text="#FFFFFF">
		
		<div align="left">
			<div id="formpje">



<?php

if (isset ($_POST['submit'])) // if the form was submitted, display their name
{
echo '&nbsp; &nbsp; Bericht is verstuurd &nbsp; &nbsp; &nbsp; &nbsp; Bedankt:&nbsp; &nbsp; '   .$_POST[voornaam]." ".$_POST[achternaam];
echo '<br> &nbsp; &nbsp; &nbsp; Naar &nbsp; <a href="http://www.helpmij.nl> index </a>' ;
}
else // form hasn't been submitted, so display the form
{
   
          


				 echo '<form method="POST" action="';
    echo htmlentities($_SERVER['PHP_SELF']);
    echo '" enctype="multipart/form-data">


				<table width="390" td height="209" align="left" cellpadding="0" cellspacing="0" text="#FFFFFF">
					
					<tr>
						<td width="128" height="28" align="left" valign="top" class="style14">
							<div align="right">
								<font face="Arial, Helvetica, sans-serif, monospace">
									<strong>
										<font color="#FFFFFF" size="2">
<!-- 	<span class="style15">
-->
											<span class="style17 style16">
												Voornaam
											</span>
											&nbsp;&nbsp;
										</font>
										<font size="2">
											&nbsp;
										</font>
									</strong>
								</font>
							</div>
						</td>
						
						<td width="262" height="28" align="left" valign="top">
							 
							<input name="voornaam" type="text" class="style1" size="40" width="262">
						</td>
					</tr>
					
					<tr>
						<td width="128" height="28" align="left" valign="top" class="style14">
							<div align="right">
								<font face="Arial, Helvetica, sans-serif, monospace">
									<strong>
										<font size="2">
											<span class="style15">
												<span class="style16 style17">
													<font color="#FFFFFF">
														Achternaam
													</font>
													&nbsp;&nbsp;&nbsp;
												</span>
											</span>
										</font>
									</strong>
								</font>
							</div>
						</td>
						<td height="28" align="left" valign="top">
							 
							<input name="achternaam" type="text" class="style1" id="achternaam" size="40" width="262">
						</td>
					</tr>
					
					<tr>
						<td width="128" height="28" align="left" valign="top" class="style14">
							<div align="right" class="style17">
								<font face="Arial, Helvetica, sans-serif, monospace">
									<strong>
										<font color="#FFFFFF" size="2">
											<span class="style16">
												Telefoonnummer&nbsp;&nbsp;&nbsp;
											</span>
										</font>
									</strong>
								</font>
							</div>
						</td>
						<td height="28" align="left" valign="top">
							 
							<input name="telefoonnummer" type="text" class="style1" id="telefoonnummer" size="40" width="262">
						</td>
					</tr>
					
					<tr>
						<td width="128" align="left" valign="top" class="style14">
							<div align="right" class="style17">
								<font face="Arial, Helvetica, sans-serif, monospace">
									<strong>
										<font color="#FFFFFF" size="2">
											<span class="style16">
												E-mailadres&nbsp;&nbsp;&nbsp;
											</span>
										</font>
									</strong>
								</font>
							</div>
						</td>
						<td height="28" align="left" valign="top">
							 
							<input name="emailadres" type="text" class="style1" id="emailadres" size="40" width="262">
						</td>
					</tr>
					
					<tr>
						<td width="128" height="44" align="left" valign="top" class="style14">
							&nbsp;
						</td>
						<td height="44" align="left" valign="top">
<textarea name="vragen" cols="37" rows="3" id="vragen" height="44" widht="255" align="left" valign="top">Heeft u verder nog vragen?
Typt u die dan hier in.
</textarea>
						</td>
					</tr>
					
					
					<tr>
						<td width="128" height="19" align="left" valign="top" td>
							&nbsp;
						</td>
						<td align="left" valign="top">
							<input type=submit value="Versturen" name="submit" >
							<input type=reset value="Opnieuw" name="reset" >
						</td>
					</tr>
				</table>




          </form>';
}

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

vervang mijn emailadres door je eigen adres.

Je code was ok, op een paar unpaired tags na, doch dit was niet het probleem.

Het probleem was dat je een ingevuld formulier wenste te vesturen.
Maar
je had geen formulier.

Na toevoeging van de form tag, en het plaatsen van de uit te voeren taak
in de form start tag wilde het formulier wel werken.

Nog wat toegevoegd:
bericht dat het verstuurd is en een link naar de index
zodat de bezoeker weer verder kan en weet dat het bericht verstuurd is.

Voorbeeld:
http://www.zeepoort.nl/tesje/form_suus5.php
 
Laatst bewerkt:
Bedankt!

Jeetje mineetje, bedankt harststikke fijn, ik ga er deze week mee aan de slag als ik weer op t werk ben, een hele fijne kerst alvast!

:thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan