Log in

View Full Version : Radio buttons at form doesn't shows in mail



jan24
11-18-2010, 03:31 PM
Hi i found a contact form on the website: http://www.phphulp.nl/php/script/data-verwerking/contact-formulier/12/contactformulierphp/1419/
Some things might be dutch so not everybody can read it all. But it also goes only about the radio button that i putted into it.

Everything is working for me here only he doesnt shows what i putted into the radio button.. does anybody know how to solve this?

Thanks in advance,
Jan24



<?php
session_start();

/*******************************
* 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.. *
********************************/

$mail_ontv = 'my@emailadres.nl';

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!ereg('^[ a-zA-Z-]+$', $_POST['naam']))
$naam_fout = 1;
if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL))
$email_fout = 1;
if (!empty($_SESSION['antiflood']))
{
$seconde = 20;
$tijd = time() - $_SESSION['antiflood'];
if($tijd < $seconde)
$antiflood = 1;
}
}

if (($_SERVER['REQUEST_METHOD'] == 'POST' && (!empty($antiflood) || empty($_POST['naam']) || !empty($naam_fout) || empty($_POST['mail']) || !empty($email_fout) || empty($_POST['blackwhite']) || empty($_POST['bericht']) || empty($_POST['onderwerp']))) || $_SERVER['REQUEST_METHOD'] == 'GET')
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!empty($naam_fout))
echo '<p>Uw naam mag alleen letters bevatten.</p>';
elseif (!empty($email_fout))
echo '<p>Uw e-mailadres is niet juist.</p>';
elseif (!empty($antiflood))
echo '<p>U mag slechts &eacute;&eacute;n bericht per ' . $seconde . ' seconde versturen.</p>';
else
echo '<p>U bent uw naam, e-mailadres, onderwerp of bericht vergeten in te vullen.</p>';
}

echo '<form method="post" action="' . $_SERVER['REQUEST_URI'] . '" />
<p>

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

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

<label for="onderwerp">Onderwerp:</label><br />
<input type="text" id="onderwerp" name="onderwerp" value="' . htmlspecialchars($_POST['onderwerp']) . '" /><br />

<label for="contactmethode">black or white*</label><br>
<input type="radio" name="blackwhite" value="' . htmlspecialchars($_POST['blackwhite']) . '" />black<br>
<input type="radio" name="blackwhite" value="' . htmlspecialchars($_POST['blackwhite']) . '" />white<br>

<br>
<label for="bericht">Bericht:</label><br />
<textarea id="bericht" name="bericht" rows="8" style="width: 400px;">' . htmlspecialchars($_POST['bericht']) . '</textarea><br />

<input type="submit" name="submit" value=" Versturen " />
</p>
</form>';
}
else
{
$datum = date('d/m/Y H:i:s');

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

$inhoud_mail .= "Naam: " . htmlspecialchars($_POST['naam']) . "\n";
$inhoud_mail .= "E-mail adres: " . htmlspecialchars($_POST['mail']) . "\n";
$inhoud_mail .= "Black or white: " . htmlspecialchars($_POST['blackwhite']) . "\n";
$inhoud_mail .= "Bericht:\n";
$inhoud_mail .= htmlspecialchars($_POST['bericht']) . "\n\n";

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

$inhoud_mail .= "===================================================\n\n";

// --------------------
// spambot protection
// ------
// 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('', '', $headers);
$headers = str_replace('', '', $headers);
$headers = str_replace(""", """, str_replace("", "", $headers));

$_POST['onderwerp'] = str_replace('', '', $_POST['onderwerp']);
$_POST['onderwerp'] = str_replace('', '', $_POST['onderwerp']);
$_POST['onderwerp'] = str_replace(""", """, str_replace("", "", $_POST['onderwerp']));

if (mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers))
{
$_SESSION['antiflood'] = time();

echo '<h1>Het contactformulier is verzonden</h1>

<p>Bedankt voor het invullen van het contactformulier. We zullen zo spoedig mogelijk contact met u opnemen.</p>';
}
else
{
echo '<h1>Het contactformulier is niet verzonden</h1>

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

jan24
11-22-2010, 01:18 PM
I edited a little bit the codes.
Although the radio button is still not working.
I got some quite hurry with this problem so if i somebody could help me with this i would be really thankful.