![]() |
| |||||||
| Support (Version 2) Here is where we provide limited support for version 2. If you are seeking support for version 3 please post in the phpLD 3.0 Support Forum. |
![]() |
| | Thread Tools | Display Modes |
| | #1 |
| Join Date: Sep 2005 Posts: 90 | Hi, First off, thanks for the great script. I'm wondering how hard it would be to add a contact page, a basic form so site visitors may contact the webmaster. I've seen a few of the sites have a contact link with a mailto: link to their email address, but I think a form would be better. The form would only need 3 fields - Name, Email, and Comment/Question. I'm thinking it would be similar to the submit.php and submit.tpl, but I'm not really sure. Would this be easy to do, or not? Thanks |
| |
| | #2 |
| Hello ing, This shouldn't be to difficult. I sent you a PM. Kind Regards -Casey __________________ Casey Wilson / Ap0s7le Freelance Programmer http://www.ap0s7le.com Need help with PHPLD? PM me | |
| |
| | #3 |
| Join Date: Jun 2005 Posts: 88 | Hi, I have the same request. How can I add a contact forum to my directory? Thanks. |
| |
| | #4 |
| Hi Ginger, I sent you a PM. If anyone else is interested, feel free to PM me directly. Thank you for your time. -Casey __________________ Casey Wilson / Ap0s7le Freelance Programmer http://www.ap0s7le.com Need help with PHPLD? PM me | |
| |
| | #5 | |
| Supporter Join Date: Sep 2005 Posts: 114 | Quote:
| |
| |
| | #6 |
| Join Date: Sep 2005 Location: Russia Posts: 56 | And me, please. |
| |
| | #7 |
| Supporter Join Date: Aug 2005 Location: Sweden Posts: 218 | Why don't you just reveal it all in the public area? :lol: |
| |
| | #8 |
| Join Date: Aug 2005 Posts: 38 | I've done this on my directory. Maybe this info should be added to the wiki? Last edited by David; 03-06-2008 at 07:37 PM. |
| |
| | #9 |
| Join Date: Aug 2005 Posts: 263 | Sounds like a good idea, webdesignpoint. Be good if you handled that, since you're the one with an operative form.... Thanks. Great site, too! __________________ {Signature Edited - Old non-working links removed} |
| |
| | #10 |
| Join Date: Aug 2005 Posts: 38 | I'll need to register on the wiki first. If the admin is ok with it, I'll put it up tomorrow or the next day. |
| |
| | #11 |
| Administrator phpLD Administrator Supporter Join Date: Jan 2005 Posts: 11,667 | Sure, go for it! |
| |
| | #12 |
| Join Date: Aug 2005 Posts: 38 | It's a nightmare trying to add this to the wiki, so I'm going to post it here instead. Create a file called 'contact.php' with the code below and place it in the root PLD folder. contact.php Code: <?php
require_once 'init.php';
session_start();
if (empty($_POST['submit']))
{
if (!empty($_SERVER['HTTP_REFERER']))
$_SESSION['return'] = $_SERVER['HTTP_REFERER'];
SmartyValidate :: connect($tpl);
SmartyValidate :: register_form('contact_form', true);
SmartyValidate :: register_criteria('isNotEqual', 'validate_not_equal', 'contact_form');
SmartyValidate :: register_validator('v_name', 'name', 'notEmpty', false, false, false, 'trim', 'contact_form');
SmartyValidate :: register_validator('v_email', 'email', 'isEmail', false, false, false, 'trim', 'contact_form');
SmartyValidate :: register_validator('v_reason', 'reason:0', 'isNotEqual', true, false, false, null, 'contact_form');
SmartyValidate :: register_validator('v_message', 'message', 'notEmpty', false, false, false, 'trim', 'contact_form');
}
else
{
SmartyValidate :: connect($tpl);
$data = array();
$data['name'] = $_POST['name'];
$data['email'] = $_POST['email'];
$data['reason'] = $_POST['reason'];
$data['message'] = $_POST['message'];
if (SmartyValidate :: is_valid($data, 'contact_form'))
{
require_once 'libs/phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->PluginDir = 'libs/phpmailer/';
$mail->Mailer = 'mail';
$mail->From = $data['email'];
$mail->FromName = $data['name'];
$mail->Subject = $data['reason'];
$mail->Body = $data['message'];
$mail->AddAddress('address@yourdomain.com', 'Your Name Here');
if (!$mail->Send())
{
$tpl->assign('error', true);
}
else
{
$tpl->assign('success', true);
}
$mail->ClearAddresses();
}
}
$path = array ();
$path[] = array ('ID' => '0', 'TITLE' => _L('Home'), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => '');
$path[] = array ('ID' => '0', 'TITLE' => _L('Contact Us'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Contact Us'));
$tpl->assign($data);
$tpl->assign('path', $path);
echo $tpl->fetch('contact.tpl');
?> contact.tpl Code: {capture name="title"} - {l}Contact Us{/l}{/capture}
{capture assign="in_page_title"}{l}Contact Us{/l}{/capture}
{capture assign="description"}{l}Contact us with queries you might have.{/l}{/capture}
{include file="header.tpl"}
{include file="top_bar.tpl"}
{include file="admin/messages.tpl"}
{if $error}
There was a problem sending the email.</p>
Please try again later.</p>
{else}
{if not $success}
<h1>{$in_page_title}</h1>
<form action="contact.php" method="post" name="contactform">
<label for="name">Full Name:</label>
<input type="text" name="name" value="{$name}" id="name" size="40" maxlength="100" />
{validate form="contact_form" id="v_name" message=$smarty.capture.field_char_required}</p>
<label for="email">Email Address:</label>
<input type="text" name="email" value="{$email}" id="email" size="40" maxlength="100" />
{validate form="contact_form" id="v_email" message=$smarty.capture.invalid_email}</p>
<label for="reason">Contact Reason:</label>
<select name="reason">
<option selected="selected"> - - select a contact reason - - </option>
<option value="advertising" label="advertising">Advertising Inquiry</option>
<option value="general" label="general">General Inquiry</option>
<option value="suggestion" label="category">New Category Suggestion</option>
<option value="other" label="other">Other (please specify)</option>
<option value="report" label="problem">Reporting a Problem</option>
<option value="feedback" label="feedback">Website Feedback</option>
</select>
{validate form="contact_form" id="v_reason" message=$smarty.capture.no_contact_reason}</p>
<label for="message">Message:</label>
<textarea name="message" id="message" rows="10" cols="50">{$message}</textarea>
{validate form="contact_form" id="v_message" message=$smarty.capture.field_char_required}</p>
<input type="submit" name="submit" value="Continue" /></p>
</form>
{else}
<h2>Thank You</h2>
Your email has been sent.</p>
{/if}
{/if}
{include file="footer.tpl"} Note: You need to change this line in contact.php: Code: $mail->AddAddress('address@yourdomain.com', 'Your Name Here'); I'll post some other details about what other changes can be made shortly. |
| |
| | #13 |
| Administrator phpLD Administrator Supporter Join Date: Jan 2005 Posts: 11,667 | Yes, the wiki is not what I had hoped it would be, mainly because we still have not figured out how to add code and images. As time allows I'll try to work toward an alternative solution. Thanks for posting the code. |
| |
| | #14 |
| Join Date: Sep 2005 Location: Australia Posts: 17 | Just added this contact form, and thought that I would share the changes I made to header.tpl It is pretty simple, and it puts the contact link to the R/H side just above the Search button Just go into the standard header.tpl file and change the Last line only to : Original line Code: <p id="desc" >{$description}</p> Code: <span id="desc" style="float:left;clear:right;">{$description}</span> <span style="float:right;">Contact Us</span> |
| |
| | #15 |
| Join Date: Nov 2005 Posts: 156 | This doesn't seem to work for me.. Here is my contact.php Code: <?php
require_once 'init.php';
session_start();
if (empty($_POST['submit']))
{
if (!empty($_SERVER['HTTP_REFERER']))
$_SESSION['return'] = $_SERVER['HTTP_REFERER'];
SmartyValidate :: connect($tpl);
SmartyValidate :: register_form('contact_form', true);
SmartyValidate :: register_criteria('isNotEqual', 'validate_not_equal', 'contact_form');
SmartyValidate :: register_validator('v_name', 'name', 'notEmpty', false, false, false, 'trim', 'contact_form');
SmartyValidate :: register_validator('v_email', 'email', 'isEmail', false, false, false, 'trim', 'contact_form');
SmartyValidate :: register_validator('v_reason', 'reason:0', 'isNotEqual', true, false, false, null, 'contact_form');
SmartyValidate :: register_validator('v_message', 'message', 'notEmpty', false, false, false, 'trim', 'contact_form');
}
else
{
SmartyValidate :: connect($tpl);
$data = array();
$data['name'] = $_POST['name'];
$data['email'] = $_POST['email'];
$data['reason'] = $_POST['reason'];
$data['message'] = $_POST['message'];
if (SmartyValidate :: is_valid($data, 'contact_form'))
{
require_once 'libs/phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->PluginDir = 'libs/phpmailer/';
$mail->Mailer = 'mail';
$mail->From = $data['email'];
$mail->FromName = $data['name'];
$mail->Subject = $data['reason'];
$mail->Body = $data['message'];
$mail->AddAddress('tmzmod@hotmail.com', 'John D');
if (!$mail->Send())
{
$tpl->assign('error', true);
}
else
{
$tpl->assign('success', true);
}
$mail->ClearAddresses();
}
}
$path = array ();
$path[] = array ('ID' => '0', 'TITLE' => _L('Home'), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => '');
$path[] = array ('ID' => '0', 'TITLE' => _L('Contact Us'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Contact Us'));
$tpl->assign($data);
$tpl->assign('path', $path);
echo $tpl->fetch('contact.tpl');
?> Code: <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="label">{capture name="title"} - {l}Contact Us{/l}{/capture} {capture assign="in_page_title"}{l}Contact
Us{/l}{/capture} {capture assign="description"}{l}Contact us with queries
you might have.{/l}{/capture} {include file="header.tpl"} {include file="top_bar.tpl"}
{include file="admin/messages.tpl"} {if $error}
There was a problem sending the email.</p>
Please try again later.</p>
{else} {if not $success}
<h1>{$in_page_title}</h1>
<form action="contact.php" method="post" name="contactform">
<label for="name">Full Name:</label>
<input type="text" name="name" value="{$name}" id="name" size="40" maxlength="100" />
{validate form="contact_form" id="v_name" message=$smarty.capture.field_char_required}</p>
<label for="email">Email Address:</label>
<input type="text" name="email" value="{$email}" id="email" size="40" maxlength="100" />
{validate form="contact_form" id="v_email" message=$smarty.capture.invalid_email}</p>
<label for="reason">Contact Reason:</label>
<select name="reason">
<option selected="selected"> - - select a contact reason - - </option>
<option value="advertising" label="advertising">Advertising Inquiry</option>
<option value="general" label="general">General Inquiry</option>
<option value="suggestion" label="category">New Category Suggestion</option>
<option value="other" label="other">Other (please specify)</option>
<option value="report" label="problem">Reporting a Problem</option>
<option value="feedback" label="feedback">Website Feedback</option>
</select>
{validate form="contact_form" id="v_reason" message=$smarty.capture.no_contact_reason}</p>
<label for="message">Message:</label>
<textarea name="message" id="message" rows="10" cols="50">{$message}</textarea>
{validate form="contact_form" id="v_message" message=$smarty.capture.field_char_required}</p>
<input type="submit" name="submit" value="Continue" />
</p>
</form>
{else}
<h2>Thank You</h2>
Your email has been sent.</p>
{/if} {/if} {include file="footer.tpl"} </td>
</tr>
</table> |
| |
| | #16 |
| Join Date: Feb 2006 Posts: 132 | Installed the contact files on an v2.0 and it was working fine. On a v3.2 installation the contact page is showing up but no emails are send... |
| |
| | #17 | |
| Quote:
No disrespect to others but I have already said to people that for a small donation to this forum and you can have a copy of mine. :wink: Last edited by David; 03-06-2008 at 07:37 PM. | ||
| |
| | #18 |
| Supporter Join Date: Dec 2005 Posts: 487 | @clubracer If it helps you troubleshoot, I have 'contact us' working in v3.02 have not touched the files since v2, seems to work fine. For now... - |
| |
| | #19 | |
| Join Date: Feb 2006 Posts: 132 | Quote:
Thnx in forward. | |
| |
| | #20 |
| Supporter Join Date: Dec 2005 Posts: 487 | Here is the child of elusive temperment, hope it works for ya: contact.php Code: <?php
require_once 'init.php';
session_start();
if (empty($_POST['submit']))
{
if (!empty($_SERVER['HTTP_REFERER']))
$_SESSION['return'] = $_SERVER['HTTP_REFERER'];
SmartyValidate :: connect($tpl);
SmartyValidate :: register_form('contact_form', true);
SmartyValidate :: register_criteria('isNotEqual', 'validate_not_equal', 'contact_form');
SmartyValidate :: register_validator('v_name', 'name', 'notEmpty', false, false, false, 'trim', 'contact_form');
SmartyValidate :: register_validator('v_email', 'email', 'isEmail', false, false, false, 'trim', 'contact_form');
SmartyValidate :: register_validator('v_reason', 'reason:0', 'isNotEqual', true, false, false, null, 'contact_form');
SmartyValidate :: register_validator('v_message', 'message', 'notEmpty', false, false, false, 'trim', 'contact_form');
}
else
{
SmartyValidate :: connect($tpl);
$data = array();
$data['name'] = $_POST['name'];
$data['email'] = $_POST['email'];
$data['reason'] = $_POST['reason'];
$data['message'] = $_POST['message'];
if (SmartyValidate :: is_valid($data, 'contact_form'))
{
require_once 'libs/phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->PluginDir = 'libs/phpmailer/';
$mail->Mailer = 'mail';
$mail->From = $data['email'];
$mail->FromName = $data['name'];
$mail->Subject = $data['reason'];
$mail->Body = $data['message'];
$mail->AddAddress(' ', ' ');
if (!$mail->Send())
{
$tpl->assign('error', true);
}
else
{
$tpl->assign('success', true);
}
$mail->ClearAddresses();
}
}
$path = array ();
$path[] = array ('ID' => '0', 'TITLE' => _L('Home'), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => '');
$path[] = array ('ID' => '0', 'TITLE' => _L('Contact Us'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Contact Us'));
$tpl->assign($data);
$tpl->assign('path', $path);
echo $tpl->fetch('contact.tpl');
?> contact.tpl Code: {capture name="title"} - {l}Contact Us{/l}{/capture}
{capture assign="in_page_title"}{l}Contact Us{/l}{/capture}
{capture assign="description"}{l}Please use this form below to contact us regarding any queries you might have.{/l}{/capture}
{include file="header.tpl"}
{include file="top_bar.tpl"}
{include file="admin/messages.tpl"}
{if $error}
There was a problem sending the email.</p>
Please try again later.</p>
{else}
{if not $success}
<h1>{$in_page_title}</h1>
<form action="contact.php" method="post" name="contactform">
<table width="50%" border="0" cellspacing="" cellpadding="" align="center">
<tr>
<td>
<label for="name">Full Name:</label>
<input type="text" name="name" value="{$name}" id="name" size="40" maxlength="100" />
{validate form="contact_form" id="v_name" message=$smarty.capture.field_char_required}</p>
<label for="email">Email Address:</label>
<input type="text" name="email" value="{$email}" id="email" size="40" maxlength="100" />
{validate form="contact_form" id="v_email" message=$smarty.capture.invalid_email}</p>
<label for="reason">Contact Reason:</label>
<select name="reason">
<option selected="selected"> - - select a contact reason - - </option>
<option value="advertising" label="advertising">Advertising Inquiry</option>
<option value="general" label="general">General Inquiry</option>
<option value="suggestion" label="category">New Category Suggestion</option>
<option value="other" label="other">Other (please specify)</option>
<option value="report" label="problem">Reporting a Problem</option>
<option value="feedback" label="feedback">Website Feedback</option>
</select>
{validate form="contact_form" id="v_reason" message=$smarty.capture.no_contact_reason}</p>
<label for="message">Message:</label>
<textarea name="message" id="message" rows="10" cols="50">{$message}</textarea>
{validate form="contact_form" id="v_message" message=$smarty.capture.field_char_required}</p>
<input type="submit" name="submit" value="Send" /></p>
</form>
{else}
<h2>Thank You</h2>
Your email has been sent.</p>
{/if}
{/if}
</td>
</tr>
</table>
{include file="footer.tpl"} - |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|