Posts: 339
Threads: 27
Joined: Nov 2009
2010-03-05, 15:10:47
(This post was last modified: 2010-03-10, 06:10:43 by ChrisFrank.)
Simple Contact Plugin v1.1
Updated: March 9th, 2010
http://internet54.com/getsimple/simple-contact-plugin
You will find a simple and easy to use contact plugin that will make it way to easy to create a usable form.
This version requires a small modification to the downloaded file. The next version will enable the ability to edit the file through the plugin panel.
With this plugin, you just have to know how to insert one line of code.
Posts: 1,848
Threads: 86
Joined: Aug 2009
this is great! now we can begin the process of pulling the contact form out of the core.
- Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Posts: 20
Threads: 8
Joined: Aug 2009
Awesome plugin. I have a suggested improvement though.
Code: /*
Added by Brian Nowell
*/
$xval = rand(1, 9);
$yval = rand(1, 9);
$sc_to = 'my@email.com'; // Your email address
$sc_captcha_question = 'What is ' . $xval . ' + ' . $yval . '?'; // The question to display for the captcha
$sc_captcha = $xval + $yval; // This will approve or disapprove the form submission upon the correct answer.
// Change this to any string.
// END CHANGES FROM Brian Nowell
Change to this and it will make the CAPTCHA dynamic. All changes made in the EDITABLE Area of plugin.
Posts: 339
Threads: 27
Joined: Nov 2009
Brian, I think that is a good option for those using addition only captcha. I wanted to make this easy so that anyone can add a simple question and answer. IE: Is GS a good program? Yes.
Posts: 20
Threads: 8
Joined: Aug 2009
We're all about simple. Here is ver. 2
Code: $question_array = array('What is 4 + 8?'=>'12','What is the capitol of Texas?'=>'Austin','What is 5 - 1?'=>'4');
$qindex = array_rand($question_array);
$sc_captcha_question = $quindex; // The question to display for the captcha
$sc_captcha = $question_array[$qindex];
See if that works.
Posts: 339
Threads: 27
Joined: Nov 2009
This would be easier. Half the people here would screw up an array.
I will try it out later today.
Code: // Create 3 questions
$q1 = 'What is 4 + 8?';
$q2 = 'What is the capitol of Texas?';
$q3 = 'What is 5 - 1?';
// The answers relative to the questions
$a1 = '12';
$a2 = 'Austin';
$a3 = '4';
$question_array = array($q1 => $a1, $q2 => $a2, $q3 => $a3);
$qindex = array_rand($question_array);
$sc_captcha_question = $quindex; // The question to display for the captcha
$sc_captcha = $question_array[$qindex];
Posts: 972
Threads: 27
Joined: Aug 2009
I’d go with an array, but one configurable through the admin panel. That will make sure people won’t screw up.
Posts: 2
Threads: 0
Joined: Mar 2010
Newbie here! Is there something I'm missing? I can't seem to get this plugin to work. I've tried installing it on both GetSimple 2.0 and 2.01 versions, I've tried different permissions settings, and I've re-read and followed the instructions several times... nothing shows up.
Got this in when I turned on debug mode:
Notice: Undefined variable: thisfile in .../plugins/simple-contact.php on line 103
Notice: Undefined variable: thisfile in .../plugins/simple-contact.php on line 104
Any thoughts?
I'd be eternally grateful to have a working contact-form plugin with CAPTCHA!
Posts: 972
Threads: 27
Joined: Aug 2009
On line 101 you’ll find the following:
Code: // Run the plugin in the theme
function sc_show() {
add_action('content-top', 'sc_mail', array($thisfile, 'Simple Contact'));
add_action('content-bottom', 'sc_form', array($thisfile, 'Simple Contact'));
}
Change these to the following:
Code: // Run the plugin in the theme
add_action('content-top', 'sc_mail', array($thisfile, 'Simple Contact'));
add_action('content-bottom', 'sc_form', array($thisfile, 'Simple Contact'));
I didn’t test it but it shouldn’t break the contact form in any way and should also fix your problem with $thisfile.
Posts: 339
Threads: 27
Joined: Nov 2009
matt Wrote:Newbie here! Is there something I'm missing? I can't seem to get this plugin to work. I've tried installing it on both GetSimple 2.0 and 2.01 versions, I've tried different permissions settings, and I've re-read and followed the instructions several times... nothing shows up.
Got this in when I turned on debug mode:
Notice: Undefined variable: thisfile in .../plugins/simple-contact.php on line 103
Notice: Undefined variable: thisfile in .../plugins/simple-contact.php on line 104
Any thoughts?
I'd be eternally grateful to have a working contact-form plugin with CAPTCHA!
Matt,
Make sure you've added this to your template (AT THE VERY TOP, LINE 1), AND that you've gone to that page and selected the template.
Code: <?php if (function_exists('sc_show')) { sc_show(); } ?>
Also, change this:
Code: function sc_show() {
add_action('content-top', 'sc_mail', array($thisfile, 'Simple Contact'));
add_action('content-bottom', 'sc_form', array($thisfile, 'Simple Contact'));
}
To this:
Code: 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'));
}
Posts: 2
Threads: 0
Joined: Mar 2010
Thanks Internet54, that did the trick!
Posts: 339
Threads: 27
Joined: Nov 2009
Updated to Version 1.1 to include the $thisfile bug fix and also a captcha array.
More install information has been added to the website as well.
Posts: 25
Threads: 8
Joined: Mar 2010
2010-03-23, 08:53:09
(This post was last modified: 2010-03-23, 08:54:30 by bobythomas.)
Excuse me for the probably stupid question but if I put <?php if (function_exists('sc_show')) { sc_show(); } ?> in the template (theme/mytheme/template.php), every pages will have the contact form no ?
So, I don't understand how to integrate it ?
Posts: 339
Threads: 27
Joined: Nov 2009
That would be correct, as long as that template is called by every page you create.
Posts: 972
Threads: 27
Joined: Aug 2009
spilarix, you can have multiple template files (PHP-files) per theme. So you’d create a contact.php file with a template for the contact page, then when creating a new page to be the contact page you can select contact.php as the template under page options.
Posts: 25
Threads: 8
Joined: Mar 2010
OK ! Very good modularity :-)
It gives me a lot of good ideas to implement.
Thank you.
Posts: 56
Threads: 19
Joined: Aug 2009
2010-04-01, 21:52:59
(This post was last modified: 2010-04-01, 21:56:00 by lantonioli.)
Hi
I tested this plugin and randomly send e-mail or said
Captcha incorrect
http://www.psychoterapiaintegra.pl/konta...oterapeuta
i also tested it on your demo site
http://internet54.com/getsimple/simple-contact-plugin
and works randomly as on my site
kotos.net - webdesign / dtp / graphics / photography
Posts: 25
Threads: 8
Joined: Mar 2010
2010-04-02, 19:07:58
(This post was last modified: 2010-04-03, 23:29:26 by bobythomas.)
Hello,
You can improve your plugin :
1 - print (with concatenations) => echo (with commas) // performance
2 - Put a real action attribute Code: echo '<form action="',htmlentities($_SERVER['REQUEST_URI']),'" method="post" class="contactform"> // Security
3 - eregi replacement : Code: if (!preg_match("/[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}/", $sc_email)){ // Php 5.3 compatibility
4 - Managing an 'h2' title with a specific class for the form by passing an optionnal param to sc_form function
Code: function sc_form ($formTitle = '')
{
...
if (!empty($formTitle))
{
echo '<h2 class="contactFormTitle">', $formTitle, '</h2>';
}
Moreover, captcha implementation can't work like this.
You are comparing a local variable with a post variable => the local variable is overwritten on POST...
So, the comparison is between the answer to the previous question and the answer to the actual question.
Posts: 15
Threads: 1
Joined: Mar 2010
i add 2 fields and form don't work:
Code: // 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;\">Adresse E-mail incorrecte.</div>";
$error = 1;
}
if ( empty($_POST['sc_name']) || empty($_POST['sc_email']) || empty($_POST['sc_website']) || empty($_POST['sc_budget']) || empty($_POST['sc_subject']) || empty($_POST['sc_message'])) {
$successmsg = "<div style=\"color:red; text-align:center;\">Remplissez tout les champs.</div>";
$error = 1;
}
if ($_POST['sc_captcha'] != $sc_captcha) {
$successmsg = "<div style=\"color:red; text-align:center;\">La réponse anti-spam est incorrecte.</div>";
$error = 1;
}
if ($error != 1){
$from = "De: " .$_POST['sc_email'];
$message = "Nom: ".$_POST['sc_name'];
$message = $message."\n". "E-mail: ".$_POST['sc_email'];
$message = "SiteWeb: ".$_POST['sc_website'];
$message = "Budget du projet: ".$_POST['sc_budget'];
$message = $message."\n". "Message: ".$_POST['sc_message'];
mail($sc_to, $_POST['sc_subject'], $message, $from);
$successmsg = "<div style=\"color:red; text-align:center;\">Merci...Votre message a rétré envoyré avec succrès.</div>";
//Clear values
$_POST = array();
}
} else {
$successmsg = "<div style=\"color:red; text-align:center;\">TOTO ???????</div>";
}
}
// Form Display
function sc_form () {
global $successmsg;
global $sc_captcha_question;
print '<div id="contact"><h2>Demande de Devis</h2>';
print $successmsg;
print '<form action="#contact" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<div class="row">
<div class="column w2">
<p>
<label for="sc_name">Nom & Prénom *</label> <input id="sc_name" name="sc_name" type="text" value="" /></p>
<p>
<label for="sc_email">Votre E-mail *</label> <input id="sc_email" name="sc_email" type="text" value="" /></p>
<p>
<label for="sc_subject">Object </label> <input id="sc_subject" name="sc_subject" type="text" value="" /></p>
</div>
<div class="column w2">
<p>
<label for="sc_website">Votre SiteWeb</label> <input id="sc_website" name="sc_website" type="text" value="" /></p>
<p>
<label for="sc_budget">Votre budget</label> <input id="sc_budget" name="sc_budget" type="text" value="" /></p>
<p>
<label for="sc_captcha">Question Anti-Spam *:</label><em style="color:green;"> '.$sc_captcha_question.'</em> <input id="sc_captcha" name="sc_captcha" type="text" value="" /></p>
</div>
</div>
<div class="row">
<p>
<label for="sc_message">Votre Projet *</label><textarea cols="40" id="sc_message" name="sc_message" rows="8"></textarea></p>
<button type="submit" id="contact-submit" name="contact-submit">Envoyer ma demande</button></div>
<input type="hidden" value="true" name="sc_submitted" />
</form>
</div>';
}
Any idea please ?
Sorry for my little english :rolleyes:
Thx for GS
Posts: 1,927
Threads: 88
Joined: Apr 2010
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><? if (function_exists('sc_show')) { sc_show(); } ?></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?
Posts: 1,927
Threads: 88
Joined: Apr 2010
mail receiving, but only 3 points
Posts: 25
Threads: 8
Joined: Mar 2010
Like I said in #18, the plugin is unusable.
Please wait for an update of the author.
Posts: 1,927
Threads: 88
Joined: Apr 2010
2010-04-07, 03:31:04
(This post was last modified: 2010-04-07, 03:34:51 by jhondavis.)
I learned how to add new elements to the form and everything works
Code: if ($error != 1){
$from = "From: " .$_POST['sc_email'];
$message = "ØüÑÂ: ".$_POST['sc_name'];
$message = $message."\n". "E-mail: ".$_POST['sc_email'];
$message = $message."\n". "Ã’þÿрþÑÂ: ".$_POST['sc_qwest']; // added element
$message = $message."\n". "âõüð: ".$_POST['sc_subject'];
$message = $message."\n". "áþþñщõýøõ: ".$_POST['sc_message'];
mail($sc_to, $_POST['sc_qq'], $message, $from); // invisible element
$successmsg = "<div style=\"color:green; text-align:center;\">Ã’ðшõ ÑÂþþñщõýøõ þтÿрðòûõýþ.</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> <select class="text" name="sc_qwest"><option>11111111</option></select></div> // added element
<div><b>âõüð:</b> <input class="text" type="text" value="" name="sc_subject" /></div>
<div style="display:none;"><b>qqqqqqqq:</b> <input class="text" type="text" value="" name="sc_qq" /></div> // invisible element
<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>';
}
Posts: 339
Threads: 27
Joined: Nov 2009
I will work on getting an update soon.
I am aware of all the issues, but I have been real busy with work and life in general.
I am going to change the mail variables to work off an array, that way the admin can add as many fields as necessary and they will be included in the sent email.
If you are having problems with not having emails sent, it's because the captcha is implemented incorrectly. Just make all 3 questions and answers the same to override the problem. Sorry.
Posts: 1,927
Threads: 88
Joined: Apr 2010
somehow have to click on a button 2-3 times to a letter dispatched
|