Hallo allemaal,
ik ben al een tijdje bezig met een bestel formulier,
(daar heb ik al vaker over gepost)
maar ik kom er nu pas achter dat er een foutje zit in de controle,
het U bent niet akkoord gegaan met de voorwaarden blijft altijd staan,
ik snap niet wat ik fout doe.


<?php
session_start(); // zorg ervoor dat session_start ALTIJD bovenaan ALLES van je pagina staat, anders werkt het niet!

/*******************************
* CONTACT FORMULIER *
* contactformulier.php *
* *
* Author: Miranda Verburg *
* Datum: 10 september 2010 *
* *
* Pas het e-mail adres aan *
* bij $mail_ontv en upload *
* het naar je webserver.. *
********************************/

// E-mailadres van de ontvanger
$mail_ontv = '*****'; // <<<----- voer jouw e-mailadres hier in!

// Speciale checks voor naam en e-mailadres
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
// naam controle
if (empty($_POST['naam']))
$naam_fout = 1;
// e-mail controle
if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL))
$email_fout = 1;
// antiflood controle
if (!empty($_SESSION['antiflood']))
{
$seconde = 20; // 20 seconden voordat dezelfde persoon nog een keer een e-mail mag versturen
$tijd = time() - $_SESSION['antiflood'];
if($tijd < $seconde)
$antiflood = 1;
}
}

// Kijk of alle velden zijn ingevuld - naam mag alleen uit letters bestaan en het e-mailadres moet juist zijn
if 
	(
		(
		$_SERVER['REQUEST_METHOD'] == 'POST' 
			&& (
				!empty($antiflood) || 
				empty($_POST['naam']) || 
				!empty($naam_fout) || 
				empty($_POST['mail']) || 
				!empty($email_fout) || 
				isset($_POST['voorwaarden'])|| 
				!isset($voorwaarden_fout))
		)|| 
		$_SERVER['REQUEST_METHOD'] == 'GET')
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!empty($naam_fout))
echo '<p>Uw naam is niet ingevuld.</p>';
elseif (!empty($email_fout))
echo '<p>Uw e-mailadres is niet juist.</p>';
elseif (!isset ($voorwaarden_fout))
echo '<p>U bent niet akkoord gegaan met de voorwaarden.</p>';
elseif (!empty($antiflood))
echo '<p>U mag slechts &eacute;&eacute;n bestelling per ' . $seconde . ' seconde versturen.</p>';
else
echo '<p>U bent uw naam of e-mailadres vergeten in te vullen.</p>';
}

// HTML e-mail formlier
echo '<form method="post" action="' . $_SERVER['REQUEST_URI'] . '">

<table border="0">
<tr>
<td><h3>Gegevens:</h3></td></tr>

<tr><td><label for="naam">Naam:</label><tr>
<tr><td><input type="text" id="naam" name="naam" value="' . (isset($_POST['naam']) ? htmlspecialchars($_POST['naam']) : '') . '" /><tr>

<tr><td><label for="mail">E-mailadres:</label><tr>
<tr><td><input type="text" id="mail" name="mail" value="' . (isset($_POST['mail']) ? htmlspecialchars($_POST['mail']) : '') . '" /></td></tr>

<tr><td><label for="URL">Site URL:</label><tr>
<tr><td>
<input type="text" id="URL" name="URL" value="' . (isset($_POST['URL']) ? htmlspecialchars($_POST['URL']) : '') . '" /></td></tr>

<tr><td><label for="donatie">Extra Donatie:</label><tr>

<tr><td>
<label for="donatie">€</label>
<input type="text" id="euro" name="euro" value="' . (isset($_POST['euro']) ? htmlspecialchars($_POST['euro']) : '0') . '" />
<label for="donatie">,</label>
<input type="text" id="cent" name="cent" value="' . (isset($_POST['cent']) ? htmlspecialchars($_POST['cent']) : '00') . '" /></td></tr>

<tr><td><h3></h3></td></tr>
<tr><td><h3>Website:</h3></td></tr>

<tr><td><label for="sidebar">- Sidebar:</label></td>
<td><input type="checkbox" id="sidebar" name="sidebar" value="' . (isset($_POST['sidebar']) ? htmlspecialchars($_POST['sidebar']) : '- Sidebar') . '" /></td>
<td>€ 5,-</td>
</tr>

<tr>
<td><label for="ontwerp">- Template:</label></td>
<td><input type="checkbox" id="ontwerp" name="ontwerp" value="' . (isset($_POST['ontwerp']) ? htmlspecialchars($_POST['ontwerp']) : '- Template') . '" /></td>
<td>€ 10,-</td>
</tr>

<tr>
<td><label for="login">- Inlogsysteem:</label></td>
<td><input type="checkbox" id="login" name="login" value="' . (isset($_POST['login']) ? htmlspecialchars($_POST['login']) : '- Inlogsysteem') . '" /></td>
<td>€ 7,50</td>
</tr>

<tr>
<td><label for="contact">- Contact Pagina:</label></td>
<td><input type="checkbox" id="contact" name="contact" value="' . (isset($_POST['contact']) ? htmlspecialchars($_POST['contact']) : '- Contact Pagina') . '" /></td>
<td>€ 3,-</td>
</tr>

<tr>
<td><label for="doneer">- Doneer systeem:</label></td>
<td><input type="checkbox" id="doneer" name="doneer" value="' . (isset($_POST['doneer']) ? htmlspecialchars($_POST['doneer']) : '- Doneer systeem') . '" /></td>
<td>€ 5,-</td>
</tr>

<tr>
<td><label for="voorbeeld">- Voorbeeld Site:</label></td>
<td><input type="checkbox" id="voorbeeld" name="voorbeeld" value="' . (isset($_POST['voorbeeld']) ? htmlspecialchars($_POST['voorbeeld']) : '- Voorbeeld Site') . '" /></td>
<td>€ 7,50</td>
</tr>

<tr>
<td><label for="blog">- Blog:</label></td>
<td><input type="checkbox" id="blog" name="blog" value="' . (isset($_POST['blog']) ? htmlspecialchars($_POST['blog']) : '- Blog') . '" /></td>
<td>€ 12,50</td>
</tr>

<tr>
<td><label for="pagina">- Pagina`s:</label></td>
<td><select name="pagina">
<option name="pagina3" value="' .(isset($_POST['pagina3']) ? htmlspecialchars($_POST['pagina']) : '') . '">3 of minder</option>
<option name="pagina35" value="' .(isset($_POST['pagina35']) ? htmlspecialchars($_POST['pagina']) : '- Pagina`s 3 t/m 5') . '">3 t/m 5</option>
<option name="pagina58" value="' .(isset($_POST['pagina58']) ? htmlspecialchars($_POST['pagina']) : '- Pagina`s 5 t/m 8') . '">5 t/m 8</option>
<option name="pagina810" value="' .(isset($_POST['pagina810']) ? htmlspecialchars($_POST['pagina']) : '- Pagina`s 8 t/m 10') . '">8 t/m 10</option>
</select></td>
<td>€ 1,- P.ST</td>
</tr>

<tr>
<td><label for="onderhoud">- Extra Onderhoud:</label></td>
<td><select name="onderhoud">
<option name="geen" value="' .(isset($_POST['geen']) ? htmlspecialchars($_POST['onderhoud']) : '') . '">Geen</option>
<option name="1 Maand" value="' .(isset($_POST['1 Maand']) ? htmlspecialchars($_POST['onderhoud']) : '- Extra Onderhoud: 1 Maand') . '">1 Maand</option>
<option name="3 Maanden" value="' .(isset($_POST['3 Maanden']) ? htmlspecialchars($_POST['onderhoud']) : '- Extra Onderhoud: 3 Maanden') . '">3 Maanden</option>
<option name="6 Maanden" value="' .(isset($_POST['6 Maanden']) ? htmlspecialchars($_POST['onderhoud']) : '- Extra Onderhoud: 6 Maanden') . '">6 Maanden</option>
<option name="12 Maanden" value="' .(isset($_POST['12 Maanden']) ? htmlspecialchars($_POST['onderhoud']) : '- Extra Onderhoud: 12 Maanden') . '">12 Maanden</option>
</select></td>
<td>€ 5,- P.M.</td>

<tr><td><h3></h3></td></tr>
<tr><td><h3>Video Montage:</h3></td></tr>

<td><label for="ondertiteling">- Ondertiteling:</label></td>
<td><input type="checkbox" id="ondertiteling" name="ondertiteling" value="' . (isset($_POST['ondertiteling']) ? htmlspecialchars($_POST['ondertiteling']) : '- Ondertiteling') . '" /> 
<td>€ 3,- Min.</td></tr>


<td><label for="stopmotion">- Stop Motion:</label></td>
<td><input type="checkbox" id="stopmotion" name="stopmotion" value="' . (isset($_POST['stopmotion']) ? htmlspecialchars($_POST['stopmotion']) : '- Stop Motion') . '" />
<td>€ 5,- Min.</td></tr>


<tr><td><h3></h3></td></tr>
<tr><td><h3>Afbeelding:</h3></td></tr>
<td><label for="photoshop">- Photoshop:</label></td>
<td><input type="checkbox" id="photoshop" name="photoshop" value="' . (isset($_POST['photoshop']) ? htmlspecialchars($_POST['photoshop']) : '- Photoshop') . '" />
<td>€ 2,50</td></tr>

<td><label for="cartoon">- Text-over Cartoon:</label></td>
<td><input type="checkbox" id="cartoon" name="cartoon" value="' . (isset($_POST['cartoon']) ? htmlspecialchars($_POST['cartoon']) : '- Text-over cartoon') . '" />
<td>€ 2,50</td></tr>

<tr><td><h3></h3></td></tr>
<tr><td><h3>Overig:</h3></td></tr>

<td><label for="powerpoint">- Powerpoint:</label></td>
<td><input type="checkbox" id="powerpoint" name="powerpoint" value="' . (isset($_POST['powerpoint']) ? htmlspecialchars($_POST['powerpoint']) : '- Powerpoint') . '" />
<td>€ 3,-</td></tr>

<td><label for="Logo">- Logo:</label></td>
<td><input type="checkbox" id="logo" name="logo" value="' . (isset($_POST['logo']) ? htmlspecialchars($_POST['logo']) : '- Logo') . '" />
<td>€ 10,-</td></td>
</tr>

<td><label for="Logo">- Gratis Logo:</label></td>
<td><input type="checkbox" id="gratislogo" name="gratislogo" value="' . (isset($_POST['gratislogo']) ? htmlspecialchars($_POST['gratislogo']) : '- Gratis Logo') . '" />
<td>€ 25,- **</td></td>
</tr>

<td><label for="Joep4U">- Joep4U+:</label></td>
<td><input type="checkbox" disabled id="Joep4U" name="Joep4U" value="' . (isset($_POST['Joep4U']) ? htmlspecialchars($_POST['Joep4U']) : '- Joep4U+') . '" />
<td>€ 7,50 *</td></td>
</tr>

</table>

<br/>
<input type="checkbox" id="voorwaarden" name="voorwaarden" value="' . (isset($_POST['voorwaarden']) ? htmlspecialchars($_POST['voorwaarden']) : ' Ik ga akkoord met de voorwaarden.') . '" />
<label for="voorwaarden">Ik ga akkoord met de voorwaarden.</label>
<input type="submit" name="submit" value=" Versturen " /> <br />

<label>* Binnenkort verkrijgbaar!</label><br />
<label>** Bij aankoop van 25 euro gratis logo</label><br />

</form>';
}

// versturen naar
else
{ 
// set datum
$datum = date('d/m/Y H:i:s');

$onderwerp .= "Bestelling: " . htmlspecialchars($_POST['naam']) . "\n";

$inhoud_mail .= "===================================================\n";
$inhoud_mail .= "Ingevulde contact formulier " . $_SERVER['HTTP_HOST'] . "\n";
$inhoud_mail .= "===================================================\n";

$inhoud_mail .= "Naam: " . htmlspecialchars($_POST['naam']) . "\n";
$inhoud_mail .= "E-mail adres: " . htmlspecialchars($_POST['mail']) . "\n";
$inhoud_mail .= "URL: " . htmlspecialchars($_POST['URL']) . "\n";
$inhoud_mail .= "Extra Donatie: " . "€ " . htmlspecialchars($_POST['euro']) . "," . htmlspecialchars($_POST['cent']) ."\n";
$inhoud_mail .= "===================================================\n";
$inhoud_mail .= "Bestelling:\n";
$inhoud_mail .= htmlspecialchars($_POST['sidebar']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['ontwerp']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['login']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['contact']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['doneer']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['voorbeeld']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['blog']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['pagina']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['onderhoud']) . "\n";
$inhoud_mail .= "===================================================\n";
$inhoud_mail .= "Video Montage:\n";
$inhoud_mail .= htmlspecialchars($_POST['ondertiteling']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['stopmotion']) . "\n";
$inhoud_mail .= "===================================================\n";
$inhoud_mail .= "Afbeelding:\n";
$inhoud_mail .= htmlspecialchars($_POST['photoshop']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['cartoon']) . "\n";
$inhoud_mail .= "===================================================\n";
$inhoud_mail .= "Overig:\n";
$inhoud_mail .= htmlspecialchars($_POST['powerpoint']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['logo']) . "\n";
$inhoud_mail .= htmlspecialchars($_POST['gratislogo']) . "\n";

$inhoud_mail .= htmlspecialchars($_POST['Joep4U']) . "\n";
$inhoud_mail .= "===================================================\n";
$inhoud_mail .= "Verstuurd op " . $datum . " via het IP adres " . $_SERVER['REMOTE_ADDR'] . "\n";
$inhoud_mail .= "===================================================\n";


// --------------------
// spambot protectie
// ------
// van de tutorial: http://www.phphulp.nl/php/tutorial/beveiliging/spam-vrije-contact-formulieren/340/
// ------

$headers = 'From: ' . htmlspecialchars($_POST['naam']) . ' <' . $_POST['mail'] . '>';

$headers = stripslashes($headers);
$headers = str_replace('\n', '', $headers); // Verwijder \n
$headers = str_replace('\r', '', $headers); // Verwijder \r
$headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes

if (mail($mail_ontv, $onderwerp , $inhoud_mail, $headers))
{
// zorg ervoor dat dezelfde persoon niet kan spammen
$_SESSION['antiflood'] = time();

echo '<h1>Uw bestelling is verzonden</h1>

<p>Bedankt voor uw bestelling. We zullen zo spoedig mogelijk contact met u opnemen.</p>';
}
else
{
echo '<h1>Uw bestelling is niet verzonden</h1>

<p><b>Onze excuses.</b> De bestelling kon niet verzonden worden.</p>';
}
} 
?>


[size=xsmall]Toevoeging op 30/08/2012 10:06:48:[/size]

Ik heb het script geüpload op http://www.htmlphp.joep4u.com/form
$voorwaarden_fout wordt nergens toegewezen en is dus altijd leeg
!isset($voorwaarden_fout) wordt dus altijd true. (regel 60)
Wat kan ik daar aan doen?
met andere woorden, de gebruiker is het nooit eens met de voorwaarden. als je die bijvoorbeeld meekrijgt van een checkbox moet je die natuurlijk in die variabele stoppen

Bijvoorbeeld:

Pagina 1:

Akkoord met de voorwaarden (
<input type='checkbox' name='akkoord'>
)

Pagina 2: (volgens mij het script wat je nu hebt gepost)

<?php
if (!isset($_POST['akkoord'])){
echo 'U moet eerst akkoord gaan met de voorwaarden.';
}
?>

Reageren