Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['contact'] == "Versturen")
- {
- $required = array("Naam", "E-mailadres");
- $valid = true;
- $html = '<style type="text/css"> body { font-family: Arial; font-size: 12px; } td { padding: 5px; border-bottom: 1px solid #F1F1F1} </style>';
- $html .= '<table width="100%" border="0" cellspacing="1" cellpadding="2">';
- $msg = array();
- foreach ($_POST as $key => $value)
- {
- if(in_array($key, $required) && (str_replace(" ", "", $value) == "" || $key == $value)){
- $valid = false;
- $msg[] = '<strong>' . $key . '</strong> is een verplicht veld';
- }
- if($key != "submit" && $key != "aanmeld-id")
- {
- $html .= '<tr>';
- $html .= '<td width="100px">' . ucfirst($key) . " : </td> <td>" . htmlspecialchars(trim($value)) . "</td>";
- $html .= '</tr>';
- }
- }
- $html .= '</table>';
- if(!preg_match("/[A-Za-z0-9_-]+([\.]{1}[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([\.]{1}[A-Za-z0-9-]+)+/",$_POST['E-mailadres'])){
- $valid = false;
- $msg[] = 'Dit is geen geldig e-mailadres';
- }
- if($valid)
- {
- $to = 'kelvin@bekent.nl';
- $subject = 'CONTACTFORMULIER VANAF BAAAKJE.nl';
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= 'From: $to' . "\r\n" .
- 'Reply-To: $to' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- if(mail($to, $subject, $html, $headers)){
- $html = "<div class='succes'>Uw gegevens zijn succesvol verstuurd. We nemen zo spoedig mogelijk contact met u op</div>";
- }
- else{
- $html = "<div class='error'>Er is een onbekende fout opgetreden</div>";
- }
- }
- else
- {
- $html = "<div class='error'><ul>";
- foreach($msg as $item){
- $html .= "<li>$item</li>";
- }
- $html .= "</ul></div>";
- }
- echo $html;
- }
- ?>
- <form method='post' action=''>
- <table>
- <tr>
- <td style='padding-right: 20px'>
- <label for='naam'>Naam:</label>
- <input size='38' type='text' name='Naam' value='' />
- <label for='Email'>E-mailadres:</label>
- <input size='38' type='text' name='E-mailadres' value='' />
- <label for='Telefoon'>Telefoonnummer:</label>
- <input size='20' maxlength='15' type='text' name='Telefoon' value='' />
- </td>
- </tr>
- <tr>
- <td>
- <input type='submit' class='submit' name="contact" value='Versturen' />
- </td>
- </tr>
- </table>
- </form>
Add Comment
Please, Sign In to add comment