Go Back   PHP Link Directory Forum > PHP Link Directory (phpLD) > Support (Version 2)

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.

Closed Thread
 
Thread Tools Display Modes
Old 09-13-2005   #1
ing
 
Join Date: Sep 2005
Posts: 90
Default Contact page?

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
ing is offline  
Old 09-13-2005   #2
Ap0s7le
 
Join Date: Jun 2005
Location: The world
Posts: 816
Send a message via ICQ to Ap0s7le Send a message via AIM to Ap0s7le Send a message via MSN to Ap0s7le Send a message via Yahoo to Ap0s7le Send a message via Skype™ to Ap0s7le
Default

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
Ap0s7le is offline  
Old 09-16-2005   #3
ginger
 
Join Date: Jun 2005
Posts: 88
Default

Hi,
I have the same request.
How can I add a contact forum to my directory?
Thanks.
ginger is offline  
Old 09-16-2005   #4
Ap0s7le
 
Join Date: Jun 2005
Location: The world
Posts: 816
Send a message via ICQ to Ap0s7le Send a message via AIM to Ap0s7le Send a message via MSN to Ap0s7le Send a message via Yahoo to Ap0s7le Send a message via Skype™ to Ap0s7le
Default

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
Ap0s7le is offline  
Old 09-16-2005   #5
senaia
Supporter
 
Join Date: Sep 2005
Posts: 114
Default

Quote:
Originally Posted by Ap0s7le
Hi Ginger,

I sent you a PM.

If anyone else is interested, feel free to PM me directly.

Thank you for your time.

-Casey
Can you please pm me also. Thanks
senaia is offline  
Old 09-17-2005   #6
Romario
 
Join Date: Sep 2005
Location: Russia
Posts: 56
Default

And me, please.
Romario is offline  
Old 09-17-2005   #7
Nobody
Supporter
 
Join Date: Aug 2005
Location: Sweden
Posts: 218
Default

Why don't you just reveal it all in the public area? :lol:
Nobody is offline  
Old 09-17-2005   #8
WebDesignPoint
 
Join Date: Aug 2005
Posts: 38
Default

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.
WebDesignPoint is offline  
Old 09-17-2005   #9
vkaryl
 
Join Date: Aug 2005
Posts: 263
Default

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}
vkaryl is offline  
Old 09-18-2005   #10
WebDesignPoint
 
Join Date: Aug 2005
Posts: 38
Default

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.
WebDesignPoint is offline  
Old 09-18-2005   #11
David
Administrator
phpLD Administrator
Supporter
 
David's Avatar
 
Join Date: Jan 2005
Posts: 11,667
Default

Sure, go for it!
David is offline  
Old 09-18-2005   #12
WebDesignPoint
 
Join Date: Aug 2005
Posts: 38
Default

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');
?>
Create a file called 'contact.tpl' with the code below and place it in the templates folder.

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"}
Add a link to your contact.php file in your header.tpl or footer.tpl or where ever you want to link to it.

Note: You need to change this line in contact.php:
Code:
$mail->AddAddress('address@yourdomain.com', 'Your Name Here');
Replace the email address with your own and the name with your name.

I'll post some other details about what other changes can be made shortly.
WebDesignPoint is offline  
Old 09-18-2005   #13
David
Administrator
phpLD Administrator
Supporter
 
David's Avatar
 
Join Date: Jan 2005
Posts: 11,667
Default

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.
David is offline  
Old 09-22-2005   #14
hosted
 
Join Date: Sep 2005
Location: Australia
Posts: 17
Default

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>
New line

Code:
<span id="desc" style="float:left;clear:right;">{$description}</span> <span style="float:right;">Contact Us</span>
* just make sure it is all on 1 line in your file
hosted is offline  
Old 02-14-2006   #15
John D
 
Join Date: Nov 2005
Posts: 156
Default

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');
?>
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>
I can't see any problems..anyone see whats wrong?
John D is offline  
Old 02-21-2006   #16
clubracer
 
Join Date: Feb 2006
Posts: 132
Default

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...
clubracer is offline  
Old 02-21-2006   #17
Kevuk2k
 
Join Date: Jan 2006
Location: Global
Posts: 567
Send a message via MSN to Kevuk2k
Default Re: Contact page?

Quote:
Originally Posted by ing
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

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.
Kevuk2k is offline  
Old 02-21-2006   #18
Neticus
Supporter
 
Neticus's Avatar
 
Join Date: Dec 2005
Posts: 487
Default

@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...

-
Neticus is offline  
Old 02-21-2006   #19
clubracer
 
Join Date: Feb 2006
Posts: 132
Default

Quote:
Originally Posted by Neticus
@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...

-
Can you send me your (working) contact files (php & tpl) without your personal (email) information?

Thnx in forward.
clubracer is offline  
Old 02-21-2006   #20
Neticus
Supporter
 
Neticus's Avatar
 
Join Date: Dec 2005
Posts: 487
Default

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"}

-
Neticus is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:00 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.