G2 Email Form?

dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Sun, 2005-03-27 18:21

hi, i'm a newbie with php. i would like to create a mail form that would be integrated into gallery (integrated for aesthetic reasons) and have a permenant link in the sidebar. i would very much appreciate it if someone could help me out with this. this would be a very useful module. thanks in advance!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-03-27 18:29

like a "email this item (link) to a friend"? or has the email nothing to do with a specific item?

either way, we will not code the module for you, we just have not enough time for all feature requests at the moment. but we can help and support you if you decide to code it yourself.

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Sun, 2005-03-27 19:39
valiant wrote:
either way, we will not code the module for you, we just have not enough time for all feature requests at the moment.

i understood that. it was really more directed at some of the knowledgable users here that happen to be generous. :D

yes, i would like a general mail form, so i'm sure this is a very simple task. i've been learning to customize certain things in G2 in baby steps but this task is over my head.

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Tue, 2005-03-29 16:50

anyone? is there a kind soul who might help out a fellow gallery user? i could trade some (unfortunately) slow server space for it. :D

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Wed, 2005-03-30 01:28

Search the intarweb at google.com for php and mail, I imagine its quite easy and there has to be sample scripts. Once you have it working in a stand alone php file, post the code here and I am sure someone can tell you where to put it to show up in G2.

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Wed, 2005-03-30 11:33

thanks! i will.

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Thu, 2005-03-31 02:25

ok, i modified the phpnuke feedback form to work in standalone. i'm no php expert, for sure. its pretty much monkey see, monkey do for my php coding, but it seems to work, so here goes:

<?php

$subject = "$sitename "._FEEDBACK."";
$adminmail = "no@spam.com";
$pagename = "Pinneo Triplets Email Form";
$note = "Please feel free to send us a note.  We look forward to hearing from family and friends.";
$yourname = "Your Name:";
$youremail = "Your Email Address:";
$yourmessage = "Message:";
$sendbutton = "Send Email";
$entername = "You forgot to tell me your name.";
$enteremail = "You forgot to enter your email address.  I can't send your email unless you give me an email address, please.";
$entermessage = "You haven't written a message yet.";
$mailwassent = "Your email has been sent.";
$thankyouemail = "Thanks for sending us an email.  We'll get back to you as soon as possible.";
/**********************************/


$form_block = "
    <center><font class=\"title\"><b>$pagename</b></font>
    <br><br><font class=\"content\">$note</font>
    <FORM METHOD=\"post\" ACTION=\"email2.php\">
    <P><strong>$yourname</strong><br>
    <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=30></p>
    <P><strong>$youremail</strong><br>
    <INPUT type=\"text\" NAME=\"sender_email\" VALUE=\"$sender_email\" SIZE=30></p>
    <P><strong>$yourmessage</strong><br>
    <TEXTAREA NAME=\"message\" COLS=60 ROWS=20 WRAP=virtual>$message</TEXTAREA></p>
    <INPUT type=\"hidden\" name=\"opi\" value=\"ds\">
    <P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"$sendbutton\"></p>
    </FORM></center>
";

if ($opi != "ds") {
    echo "$form_block";
} elseif ($opi == "ds") {
    if ($sender_name == "") {
	$name_err = "<center><font class=\"option\"><b><i>$entername</i></b></font></center><br>";
	$send = "no";
    } 
    if ($sender_email == "") {
	$email_err = "<center><font class=\"option\"><b><i>$enteremail</i></b></font></center><br>";
	$send = "no";
    } 
    if ($message == "") {
    	$message_err = "<center><font class=\"option\"><b><i>$entermessage</i></b></font></center><br>";
	$send = "no";
    } 
    if ($send != "no") {
	$msg = "$sitename\n\n";
	$msg .= ""._SENDERNAME.": $sender_name\n";
	$msg .= ""._SENDEREMAIL.": $sender_email\n";
	$msg .= ""._MESSAGE.": $message\n\n";
	$to = $adminmail;
	$mailheaders = "From: $sender_name <$sender_email>\n";
	$mailheaders .= "Reply-To: $sender_email\n\n";
	mail($to, $subject, $msg, $mailheaders);
	echo "<P><center>$mailwassent</center></p>";
	echo "<P><center>$thankyouemail</center></p>";
    } elseif ($send == "no") {
	echo "$name_err";
	echo "$email_err";
	echo "$message_err";
	echo "<br><br>";
	echo "$form_block";  
    } 
}


?>
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-03-31 06:21

erm, G2 has built-in email functions, i.e. it sens emails on registration of new users. your job wouldn't be to create an email function, but to build a module with its logic and views to let you choose what you want to email to which users (view) and to handle the inputs from the view (controller).

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Thu, 2005-03-31 12:57

that's not exactly what i'm after. i have users and new user registration turned off. the only users are guest and admin. the purpose of the form is for general feedback or contact - basically a way to contact me without having to divulge my email address on the page.

a module is exactly what i'm hoping to achieve - a way to integrate the form into G2 so that its aesthetically the same as the rest of the site. this form works, and i could just link to it in the sidebar or something, but that's an ugly way to do it.

i was using phpnuke and embedded G1, which worked well, but the nuke site was too busy. people coming to my site just want to see pictures anyway. they don't want to mess around with logging in (i learned that from my experience with the nuke site). there are just a couple of features that i had in nuke that i would like to get into G2: a mail form and a site faq. if i can get over the hump here with the mail form, i'm sure i can do the faq on my own. i just need a nudge in the right direction.

by the way, one reason i dumped nuke altogether was that G2 works so well and is better looking. G2 is awesome! kudos on a great job! it works so well, i'm hosting a few G2 sites for friends and family (with kids... :D ).

also, thanks for your help so far.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2005-03-31 15:39

a module can add links to the top bar (system links) or content in the sidebar (system content) and of course can add new pages (views). you can look at the cart module as a starting point.. it adds system content and has its own view. look at useralbum module to see how to add a system link (your album). http://smarty.php.net/ for documentation on the format of the tpl files.

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Fri, 2005-04-01 01:42

thanks! i'll give it a whack tonight.

 
dj-3plet

Joined: 2005-03-12
Posts: 70
Posted: Mon, 2005-04-18 11:52

ok, thanks to bharat and krill, i've got the modules going. i made one faq module and i started the email module.

i added the php script to my email.inc file and the script works, but there are a couple of problems.

1) when the page loads, the email form appears above the page header and sidebar; and the formatting is all messed up.

2) the confirmation page is (as shown in the script above) email.php - so after you hit "send", email.php loads and there is no header, sidebar, etc - but it does say "thanks for sending email.. blah blah blah..."

i don't know how to call it back to the module. email.php is located in the root folder (that's the original thing i was playing around with).

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Thu, 2005-04-21 05:00

Publish what you have and we'll take a look and give you feedback. Thanks!