groups

info


tags: php,pluskit,contact,form

Link to this snippet:


Download to Code Collector

language: PHP
licence: Other

PlusKit PHP Contact Form Solution

options: send to code collectorview all seydoggy's snippets
<?php
        //start session
        session_start();
        
        //set a key, checked in mailer, prevents against 
         //spammers trying to hijack the mailer.
        $security_token = $_SESSION['security_token'] = uniqid(rand());
        
        if(!isset($_SESSION['formMessage'])) $_SESSION['formMessage'] =
                                                    'Fill in the form below to send me an email.';
        if(!isset($_SESSION['formFooter'])) $_SESSION['formFooter'] = '';
        
        if(!isset($_SESSION['form'])) $_SESSION['form'] = array();
        
        function check($field, $type = "", $value = "") {
                $string = "";
                if(isset($_SESSION['form'][$field])) {
                        switch($type) {
                                case "checkbox":
                                        $string = 'checked="checked"';
                                        break;
                                case "radio":
                                        if($_SESSION['form'][$field] == $value) 
                                                 $string = 'checked="checked"';
                                        break;
                                case "select":
                                        if($_SESSION['form'][$field] == $value) 
                                                 $string = 'selected="selected"';
                                        break;
                                default:
                                        $string = unescape_string($_SESSION['form'][$field]);
                        }
                }
                return $string;
        }
        
        function unescape_string($string) {
                return stripslashes(@ html_entity_decode($string, ENT_QUOTES));
        }
?>