Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Contact Plugin
#51
Thank you for work!

How can attach any files to emails?

thanks.
Sorry for my English ;)
Reply
#52
Hi there,

i tried to make some customization for getting a "call me" - form. But it doens't send any email. Maybe because i deleted the captcha?

Would be awesome, if somebody could help me.

Thank you very much!

You can find the website here: http://solarshare.martonos.de

Code:
<?php

$sc_to = 'my-emailadress';

# 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
);

add_action('plugins-sidebar', 'createSideMenu', array($thisfile, 'Simple Contact'));
/////////////////////////////////////////

// Show options in plugin page
function sc_options() {
    print "<h2>How to get this thing working?</h2>
    <p>Please add this line of code in your template files where you want your contact form to display. For example
    place this code into your contact template file so it displays on that page.  This plugin is set to display the form right below the content of the page.<br />
    <p><strong>if (function_exists('sc_show')) { sc_show(); }</strong><br />
    Make sure to wrap it in php tags.</p>";
}

// PHP mail function
function sc_mail () {
    global $successmsg;
    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_zeit'])) {
            $successmsg = "<p class=\"error\"><a href=\"#rueckruf\">Bitte alle Felder ausfüllen &raquo;</a> - <a href=\"#rueckruf\" onclick=\"return false\"  class=\"hide2\">Nachricht ausblenden</a></p>";
            $error = 1;
        }

        if ($error != 1){
            $from = "From: " .$_POST['sc_email'];
            $message = "Name: ".$_POST['sc_name'];
            $message = $message."\n". "Name: ".$_POST['sc_name'];
            $message = $message."\n". "Telefonnummer: ".$_POST['sc_nummer'];
            $message = $message."\n". "Wunschzeit: ".$_POST['sc_zeit'];
            mail($sc_to, $_POST['sc_subject'], $message, $from);
            $successmsg = "<p class=\"success\">Vielen Dank, wir haben ihren Rückrufwunschtermin erhalten.<br /> <a href=\"#\" class=\"hide\" onclick=\"return false\">Nachricht ausblenden &raquo;</a></p>";
            //Clear values
            $_POST = array();
        }
    } else {
        $successmsg = "";
    }
}

// Form Display
function sc_form () {
    global $successmsg;
    print '<div id="sc-container">';
    print $successmsg;
    print '<form action="" method="post" id="rueckruf" class="contactform" >
    <div><label>Name:</label> <input class="text" type="text" value="" name="sc_name" /></div>
    <div><label>Telefonnummer:</label> <input class="text" type="text" value="" name="sc_nummer" /></div>    
    <div><label>Gewünschte Rückrufzeit</label> <textarea class="text" name="sc_zeit" ></textarea></div>    
    <input type="hidden" value="Rückrufformular - solarshare.de" name="sc_subject" />
    <input type="hidden" value="formular@solarshare.de" name="sc_email" />
    <div><input type="submit" value="Abschicken" 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'));
}
?>
Reply
#53
martonos Wrote:Hi there,

i tried to make some customization for getting a "call me" - form. But it doens't send any email. Maybe because i deleted the captcha?

Would be awesome, if somebody could help me.

Thank you very much!

You can find the website here: http://solarshare.martonos.de

Ok when i fill the form in and press send i get the message
"Vielen Dank, wir haben ihren Rückrufwunschtermin erhalten.
Nachricht ausblenden »"

Which i am assuming is the success message

2 things to try

1) Instead of having a successmessage come up, set it so that it echos the variables
mail($sc_to, $_POST['sc_subject'], $message, $from);
$successmsg = "<p class=\"success\">sc_to = ".$sc_to." Subject = ".$_POST['sc_subject']."</p>";
Something like that anyway
2) otherwise try hardcoding the email address

$sc_to = "me@myaddress.com";
mail($sc_to, $_POST['sc_subject'], $message, $from);

also try using different email address just to make sure your emails aren't getting eaten by a spam filter somewhere
Reply
#54
Man, I need to update this thing.
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#55
Quote:Man, I need to update this thing.

Hi David,
try out my little modification of your plugin and tell me what do you think...
Reply
#56
thx for this wonderful plugin for the first of all.

now i got questions:
1. i need to retry 3 times to send an email successfully even i got the ANSWER right on each time...
2. no email receiving after it sent successfully...

hope can get some help from here!

thx in advance.
Reply
#57
^ It's a problem with the captcha not being setup correctly.

Look for a line like this:
$question_array = array($q1 => $a1, $q2 => $a2, $q3 => $a3);

and change to this:
$question_array = array($q1 => $a1);
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#58
internet54 Wrote:^ It's a problem with the captcha not being setup correctly.

Look for a line like this:
$question_array = array($q1 => $a1, $q2 => $a2, $q3 => $a3);

and change to this:
$question_array = array($q1 => $a1);
Hi Internet 54

have a look at post 34 or 39 in this thread, there is a modded version of your contact form that has captcha working correctly (allows multiple questions) and it also works around a php 5.1 bug
Reply
#59
internet54 Wrote:^ It's a problem with the captcha not being setup correctly.

Look for a line like this:
$question_array = array($q1 => $a1, $q2 => $a2, $q3 => $a3);

and change to this:
$question_array = array($q1 => $a1);


thx internet54

now the problem one has solved!

remains the problem two...

: (
Reply
#60
fotothink Wrote:2. no email receiving after it sent successfully...

Check this line
Code:
$sc_to = "me@myaddress.com";
Reply
#61
vsky Wrote:
fotothink Wrote:2. no email receiving after it sent successfully...

Check this line
Code:
$sc_to = "me@myaddress.com";


yeah man i know, replacing your email address is the first thing to do, haven't forgot this step. but the still no show...

confusing here...
Reply
#62
Do you use it locally? If not
try to use the 2nd method:
Code:
Add this code above your <html> tag call.
<?php if (function_exists('sc_mail')) { sc_mail(); } ?>

And, add this anywhere on the page to display the form.
<?php if (function_exists('sc_form')) { sc_form(); } ?>
Reply
#63
vsky Wrote:Do you use it locally? If not
try to use the 2nd method:
Code:
Add this code above your <html> tag call.
<?php if (function_exists('sc_mail')) { sc_mail(); } ?>

And, add this anywhere on the page to display the form.
<?php if (function_exists('sc_form')) { sc_form(); } ?>

thx for helping out there man.

now that i think i ve found the missing point:

Add this code above your <html> tag call.
<?php if (function_exists('sc_mail')) { sc_mail(); } ?>


is here where it should be placed?

<?php if (function_exists('sc_mail')) { sc_mail(); } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Reply
#64
Yes, the first or the second line Smile
Reply
#65
vsky Wrote:Yes, the first or the second line Smile

i ve tried.

it kills me, the problem still remains. no email receiving...

: (
Reply
#66
GREAT PLUGIN, haven't installed it yet Sad

The dynamic CAPTCHA from Brian is also used by CMS sNews (see below) i've been using for years.
But since yesterday i've changed to GetSimple !

Code:
// MATH CAPTCHA
function mathCaptcha() {
    $x = rand(1, 9);
    $y = rand(1, 9);
    $_SESSION[_SITE.'mathCaptcha-digit'] = $x + $y;
    $math = '
        <p><label for="calc">
            * '.l('math_captcha').':
        </label><br />';
    $math .= $x.' + '.$y.' = ';
    $math .= '
        <input type="text" name="calc" id="calc" />
        </p>';
    return $math;
}

// CHECK MATH CAPTCHA RESULT
function checkMathCaptcha() {
    $result = false;
       $testNumber = isset($_SESSION[_SITE.'mathCaptcha-digit']) ? $_SESSION[_SITE.'mathCaptcha-digit'] : 'none';
       unset($_SESSION[_SITE.'mathCaptcha-digit']);
       if (is_numeric($testNumber) && is_numeric($_POST['calc']) && ($testNumber == $_POST['calc'])) {
        $result = true;
    }
       return $result;
}
Reply
#67
Internet54 thanks for great plugin! Have no problems with it except CAPTCHA. So I added a securimage captcha.
Hope it will help someone.
1. Download lastest version of secureimage and copy it to root folder of your site. For more details see CAPTCHA homepage above.
2. Replace plugin code with the code below:
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 = 'YOUR_ADRESS_HERE';

// 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, 'Simple Contact'));
/////////////////////////////////////////

// Show options in plugin page
function sc_options() {
    echo "<h2>How to get this thing working?</h2>
    <p>Please add this line of code in your template files where you want your contact form to display. For example
    place this code into your contact template file so it displays on that page.  This plugin is set to display the form right below the content of the page.<br />
    <p><strong>if (function_exists('sc_show')) { sc_show(); }</strong><br />
    Make sure to wrap it in php tags.</p>";
}

// PHP mail function
function sc_mail () {

    global $successmsg;
    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 (sc_check()) {
            $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:green; text-align:center;\">Thank you... The form was successfully sent.</div>";
            //Clear values
            $_POST = array();
        }
    } else {
        $successmsg = "";
    }
}

function sc_check() {

    session_start();
    require_once('./securimage/securimage.php');

    $securimage = new Securimage();
    if ($securimage->check($_POST['sc_captcha']) == false)
        return 1;

    return 0;
}

// Form Display
function sc_form () {
    global $successmsg;
    global $sc_captcha_question;
    global $sc_captcha;
    print '<div id="sc-container">';
    echo $successmsg;
    <div><b>Name:</b> <input class="text" type="text" value="" name="sc_name" /></div>
    <div><b>Email:</b> <input class="text" type="text" value="" name="sc_email" /></div>
    <div><b>Subject:</b> <input class="text" type="text" value="" name="sc_subject" /></div>
    <div><b>Message:</b> <textarea class="text" name="sc_message" ></textarea></div>
    <div><b>Please enter symbols from the picture below:</b><img id="captcha" src="../securimage/securimage_show.php" alt="CAPTCHA image" title="Reload image" onclick="document.getElementById(\'captcha\').src = \'/securimage/securimage_show.php?\' + Math.random(); return false" /><br /> <input class="text" type="text" value="" name="sc_captcha" maxlength="6" /></div>
    <div><input type="submit" value="Send" 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'));
}
?>
}
3. Thus we have nice dynamic click-to-reload CAPTCHA (see pic in attachment) with a lot of options in contact plugin in just about 5 lines of additional code.
4. Tnx internet54 again Wink
Reply
#68
Hello, it's a nice plugin indeed.
What's the license you're using to distribute it? I can't find any mention of it...
Reply
#69
vsky Wrote:
Quote:Man, I need to update this thing.

Hi David,
try out my little modification of your plugin and tell me what do you think...

I have translated your mod into polish (separate language version) but it does not support UTF-coding, which would the best solution for a contact form.

Michal
Reply
#70
rozmiar Wrote:I have translated your mod into polish (separate language version) but it does not support UTF-coding, which would the best solution for a contact form.

Hi Michal,

you should save polish lang file in UTF-8 without BOM (it is also called ANSI as UTF). Do not save it as ANSI.
Reply
#71
vsky Wrote:
rozmiar Wrote:I have translated your mod into polish (separate language version) but it does not support UTF-coding, which would the best solution for a contact form.

Hi Michal,

you should save polish lang file in UTF-8 without BOM (it is also called ANSI as UTF). Do not save it as ANSI.

Thank for a reply. I figured it out. The contact form is now translated into polish. I have another issue. It looks like that the emails are not encoded in UTF. If i download the messages via Outlook i can`t read them and the name of the sender ist the name of mu server. Can i change this?

You can see it in the attachment file.

Thanks for any help
Reply
#72
So how do I actually edit the fields which show up in the contact form? Do I have to edit simple-contact.php?

When I try to edit it it says: Dynamically related files cannot be discovered because there is no site definition for this document.

Some other guy installed this and it seems to work fine, I just don't know how to edit the fields.

Thanks!
Reply




Users browsing this thread: 2 Guest(s)