Topic: Contact Form
Something I made for users to have to make it easily accessible on the forums to contact the administrator (or set user). This is my first mod, so tell me if there is something that I left out in this post. I am almost 100% positive that I have everything correct.
Step 1:
Copy the following code and save as "contactform.php" in your forum folder. Edit line #34 and enter you email address to be sent to.
<?php
##
##
## Mod title: Contact Form
##
## Mod version: 1.0
## Works on PunBB: 1.2.15
## Release date: 2005-04-28
## Author: Sam Rusch (pghmyn@gmail.com)
##
## Description: Gives users a chance to have a simple and easy contact form on their
## forums for all their users.
##
## Affected files: functions.php
##
## Affects DB: No
##
## Notes: Easy to edit yourself, and feel free to edit this. If you would like
## to spice up the look of the form, it's up to you. The form is not the
## best, but it will do for what it is made for.
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
//** What EMail should the message be sent to?
$sendto = "youremailhere";
//** Do not edit below this line, unless you know what you are doing.
if ($_POST['send']) {
$name = trim($_POST['Name']);
$email = trim($_POST['email']);
$topic = trim($_POST['topic']);
$details = trim($_POST['details']);
$headers = "From: ".$name." at ".$email." \r\n";
$headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "MIME-Version: 1.0 ";
mail($sendto, "Suggestion/Concern (".$topic.")", $details, $headers);
$confirm = "Your message has been successfully sent! If you entered an email, you may have a reply shortly.<br /><br />";
}
?>
<form method="post" action="">
<div class="blocktable">
<h2><span>Contact Form</span></h2>
<div class="box">
<div class="inbox">
<table cellspacing="0">
<tr>
<th class="tcl" scope="col">Please fill out the form below to send it in an EMail message:</th>
</tr>
<tr>
<td>
<div class="infldset">
<?php
if (isset($confirm)) {
echo $confirm;
}
?>
<b>Your Name</b> (required) <input type="text" name="Name" size="30" /><br />
<b>Your EMail</b> <input type="text" name="email" size="30" /><br />
<b>Suggestion/Concern</b> (required) <input type="text" name="topic" size="35" /><br /><br />
<b>Details</b> (required)<br /><textarea rows="4" cols="60" name="details"></textarea><br />
<input type="submit" name="send" value="Send Now!" />
</div
</td>
</tr>
</table>
</div>
</div>
</div>
</form>
<?php
$footer_style = 'index';
require PUN_ROOT.'footer.php';
Step 2:
Look for the functions.php file in the include folder. Search for the function "function generate_navlinks()" on line 291. The first few lines are what you edit, and they should like like this when you are done:
function generate_navlinks()
{
global $pun_config, $lang_common, $pun_user;
// Index and Userlist should always be displayed
$links[] = '<li id="navindex"><a href="index.php">'.$lang_common['Index'].'</a>';
$links[] = '<li id="navuserlist"><a href="userlist.php">'.$lang_common['User list'].'</a>';
$links[] = '<li id="navlogin"><a href="contactform.php">Contact Form</a>';
Step 3:
You are finished and ready to have the contact form working!