Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Contact Plugin
#20
My messages are not sent
Code:
<?php
////////////////////////////////////////////////////////
// Simple Contact v1.1 for GetSimple 2.X
// Plugin created by internet54 - http://internet54.com/
// Author: David Guerra - david@internet54.com
// Last Edited on March 9th, 2010
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
// EDITABLE OPTIONS

// Your email address
$sc_to = 'bes64@mail.ru';

// Create 3 questions
$q1 = 'Сложите 4 + 8?';
$q2 = 'Столица России?';
$q3 = 'Мы живем на Марсе?';
// The answers relative to the questions
$a1 = '12';
$a2 = 'Москва';
$a3 = 'нет';
// DO NOT EDIT PAST THIS LINE
////////////////////////////////////////////////////////

# get correct id for plugin
$thisfile = basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile,    # ID of plugin, should be filename minus php
    'Simple Contact',    # Title of plugin
    '1.1',    # Version of plugin
    'internet54',    # Author of plugin
    'http://internet54.com',    # Author URL
    'This plugin will install a simple contact form into your website.',    # Plugin Description
    'plugins',    # Page type of plugin
    'sc_options'    # Function that displays content
);

# Creates a menu option on the Admin/Theme sidebar
//add_action('admin-menu','createSideMenu',array($thisfile,'Plugin Gal'));
add_action('plugins-sidebar', 'createSideMenu', array($thisfile, 'Контактная форма'));
/////////////////////////////////////////

// Captcha maker thanks to Brian Nowell for the input
$question_array = array($q1 => $a1, $q2 => $a2, $q3 => $a3);
$qindex = array_rand($question_array);

$sc_captcha_question = $qindex;
$sc_captcha = $question_array[$qindex];

// Show options in plugin page
function sc_options() {
    print "<h2>Как создать форму с каптчей?</h2>
    <p>Создайте страницу \"Контакты\".<br />
    <p>Вставьте ниже, выше или вместо текста вот этот код: <strong>&lt;? if (function_exists('sc_show')) { sc_show(); } ?&gt;</strong><br />
    ÃÂ˜ все? И все...</p>";
}

// PHP mail function
function sc_mail () {
    global $successmsg;
    global $sc_captcha;
    global $sc_to;
    $error = 0;
    if( isset($_POST['sc_submitted']) ) {
        $sc_email = $_POST['sc_email'];
        if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$sc_email )){
            $successmsg = "<div style=\"color:red; text-align:center;\">Invalid email address entered.</div>";
            $error = 1;
        }
        if ( empty($_POST['sc_name']) || empty($_POST['sc_email']) || empty($_POST['sc_subject']) || empty($_POST['sc_message'])) {
            $successmsg = "<div style=\"color:red; text-align:center;\">Please fill out all fields.</div>";
            $error = 1;
        }
        if ($_POST['sc_captcha'] != $sc_captcha) {
            $successmsg = "<div style=\"color:red; text-align:center;\">Captcha answer incorrect.</div>";
            $error = 1;            
        }
        if ($error != 1){
            $from = "From: " .$_POST['sc_email'];
            $message = "Name: ".$_POST['sc_name'];
            $message = $message."\n". "E-mail: ".$_POST['sc_email'];
            $message = $message."\n". "Message: ".$_POST['sc_message'];
            mail($sc_to, $_POST['sc_subject'], $message, $from);
            $successmsg = "<div style=\"color:red; text-align:center;\">Thank you... The form was successfully sent.</div>";
            //Clear values
            $_POST = array();
        }
    } else {
        $successmsg = "";
    }
}

// Form Display
function sc_form () {
    global $successmsg;
    global $sc_captcha_question;
    print '<div id="sc-container">';
    print $successmsg;
    echo '<form action="" method="post" class="contactform">
    <div><b>Имя:</b> <input class="text" type="text" value="" name="sc_name" /></div>
    <div><b>E-mail:</b> <input class="text" type="text" value="" name="sc_email" /></div>
    <div><b>Тема:</b> <input class="text" type="text" value="" name="sc_subject" /></div>
    <div><b>Вопрос:</b> <select name="qwest"><option selected="selected">2222</option><option>333</option></select></div>
    <div><b>Сообщение:</b> <textarea class="text" name="sc_message" ></textarea></div>
    <div><b>Каптча:</b> '.$sc_captcha_question.'<br /> <input class="text" type="text" value="" name="sc_captcha" /></div>
    <div><input type="submit" value="Отправить" id="contact-submit" name="contact-submit" /></div>
    <input type="hidden" value="true" name="sc_submitted" />
    </form>
    </div>';
}

// Run the plugin in the theme
function sc_show() {
    global $thisfile;
    add_action('content-top', 'sc_mail', array($thisfile, 'Simple Contact'));
    add_action('content-bottom', 'sc_form', array($thisfile, 'Simple Contact'));
}
?>

wrong?
Reply


Messages In This Thread
Simple Contact Plugin - by internet54 - 2010-03-05, 15:10:47
Simple Contact Plugin - by ccagle8 - 2010-03-05, 21:30:59
Simple Contact Plugin - by bnowell - 2010-03-06, 00:37:46
Simple Contact Plugin - by internet54 - 2010-03-06, 01:14:11
Simple Contact Plugin - by bnowell - 2010-03-06, 02:21:06
Simple Contact Plugin - by internet54 - 2010-03-06, 02:34:36
Simple Contact Plugin - by Zegnåt - 2010-03-06, 03:40:10
Simple Contact Plugin - by matt - 2010-03-06, 04:48:05
Simple Contact Plugin - by Zegnåt - 2010-03-06, 07:12:28
Simple Contact Plugin - by internet54 - 2010-03-06, 08:50:02
Simple Contact Plugin - by matt - 2010-03-06, 10:07:35
Simple Contact Plugin - by internet54 - 2010-03-10, 06:11:38
Simple Contact Plugin - by spilarix - 2010-03-23, 08:53:09
Simple Contact Plugin - by internet54 - 2010-03-23, 11:08:04
Simple Contact Plugin - by Zegnåt - 2010-03-23, 16:33:26
Simple Contact Plugin - by spilarix - 2010-03-24, 01:21:17
Simple Contact Plugin - by kotos - 2010-04-01, 21:52:59
Simple Contact Plugin - by spilarix - 2010-04-02, 19:07:58
Simple Contact Plugin - by mouffin - 2010-04-04, 01:36:09
Simple Contact Plugin - by Oleg06 - 2010-04-04, 05:25:31
Simple Contact Plugin - by Oleg06 - 2010-04-06, 19:52:27
Simple Contact Plugin - by spilarix - 2010-04-07, 00:22:19
Simple Contact Plugin - by Oleg06 - 2010-04-07, 03:31:04
Simple Contact Plugin - by internet54 - 2010-04-07, 08:08:01
Simple Contact Plugin - by Oleg06 - 2010-04-11, 00:59:53
Simple Contact Plugin - by banter - 2010-04-12, 07:00:09
Simple Contact Plugin - by El-Cherubin - 2010-05-17, 05:25:53
Simple Contact Plugin - by morgenmuffel - 2010-05-17, 10:28:02
Simple Contact Plugin - by an8dres26h - 2010-05-18, 04:46:13
Simple Contact Plugin - by morgenmuffel - 2010-05-18, 07:06:26
Simple Contact Plugin - by Oleg06 - 2010-05-18, 16:13:52
Simple Contact Plugin - by an8dres26h - 2010-05-19, 01:14:12
Simple Contact Plugin - by morgenmuffel - 2010-05-19, 07:41:23
Simple Contact Plugin - by morgenmuffel - 2010-05-19, 08:46:10
Simple Contact Plugin - by NickC - 2010-05-20, 20:06:54
Simple Contact Plugin - by an8dres26h - 2010-05-21, 02:34:15
Simple Contact Plugin - by samrayner - 2010-05-22, 21:07:35
Simple Contact Plugin - by Oleg06 - 2010-05-22, 23:45:58
Simple Contact Plugin - by morgenmuffel - 2010-05-23, 08:38:12
Simple Contact Plugin - by Oleg06 - 2010-05-23, 16:22:13
Simple Contact Plugin - by cscott - 2010-06-17, 06:05:17
Simple Contact Plugin - by folieplus - 2010-07-07, 20:25:08
Simple Contact Plugin - by yojoe - 2010-07-08, 03:44:37
Simple Contact Plugin - by folieplus - 2010-07-08, 19:31:33
Simple Contact Plugin - by suprchic66 - 2010-07-09, 06:32:20
Simple Contact Plugin - by morgenmuffel - 2010-07-17, 10:30:35
Simple Contact Plugin - by Zegnåt - 2010-07-17, 20:06:32
Simple Contact Plugin - by morgenmuffel - 2010-07-20, 14:36:14
Simple Contact Plugin - by core - 2010-07-22, 00:26:25
Simple Contact Plugin - by simple123 - 2010-07-29, 04:33:28
Simple Contact Plugin - by NeBox - 2010-08-06, 23:35:36
Simple Contact Plugin - by martonos - 2010-08-07, 02:31:57
Simple Contact Plugin - by morgenmuffel - 2010-08-07, 09:57:27
Simple Contact Plugin - by internet54 - 2010-08-19, 13:19:34
Simple Contact Plugin - by vsky - 2010-08-19, 15:03:21
Simple Contact Plugin - by fotothink - 2010-08-19, 20:46:53
Simple Contact Plugin - by internet54 - 2010-08-19, 23:08:19
Simple Contact Plugin - by morgenmuffel - 2010-08-20, 07:18:25
Simple Contact Plugin - by fotothink - 2010-08-20, 18:34:56
Simple Contact Plugin - by vsky - 2010-08-20, 20:33:32
Simple Contact Plugin - by fotothink - 2010-08-20, 21:09:38
Simple Contact Plugin - by vsky - 2010-08-20, 21:19:45
Simple Contact Plugin - by fotothink - 2010-08-21, 01:20:17
Simple Contact Plugin - by vsky - 2010-08-21, 05:01:29
Simple Contact Plugin - by fotothink - 2010-08-21, 15:26:25
Simple Contact Plugin - by Rene - 2010-08-25, 17:19:12
Simple Contact Plugin - by 9dogs - 2010-09-04, 09:24:25
Simple Contact Plugin - by tankmiche - 2010-09-12, 20:13:12
Simple Contact Plugin - by rozmiar - 2010-09-15, 23:35:27
Simple Contact Plugin - by vsky - 2010-09-16, 09:25:19
Simple Contact Plugin - by rozmiar - 2010-09-24, 19:50:14
Simple Contact Plugin - by mikesalami - 2011-04-08, 09:49:36



Users browsing this thread: 1 Guest(s)