MyBB Community Forums

Full Version: I need a contact us page...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need a contact us page in my forums...
A simple one without captcha...

I tried this http://mods.mybb.com/view/contact-us-form
But, it didn support my version...

mine is 1.6.9

I got a PHP file
<?php

# MyBB Page Manager - Contact
# Updated for reCAPTCHA support by MyBBStyles.com
# Installation instructions and support: http://www.mybbstyles.com/thread-new-page-mybb-contact-form-with-recaptcha

global $headerinclude, $header, $theme, $footer, $templates, $lang;
require_once MYBB_ROOT.'inc/class_captcha.php';

$lang->load('member');
$lang->load('messages');
$lang->load('datahandler_user');

$subject = htmlspecialchars_uni(trim($mybb->input['subject']));
$message = htmlspecialchars_uni(trim($mybb->input['message']));

if(!$mybb->user['uid'])
{
	$name = htmlspecialchars_uni(trim($mybb->input['name']));
	$email = htmlspecialchars_uni(trim($mybb->input['email']));

	$usertemplate = '<tr>
<td width="40%" class="trow1"><strong>{$lang->full_name}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="name" value="{$name}" /></td>
</tr>
<tr>
<td width="40%" class="trow2"><strong>{$lang->email_address}</strong></td>
<td width="60%" class="trow2"><input type="text" class="textbox" size="50" name="email" value="{$email}" /></td>
</tr>';

	$usertemplate = str_replace("\'", "'", addslashes($usertemplate));

	eval("\$usertemplate = \"" . $usertemplate . "\";");
}
else
{
	$name = $mybb->user['username'];
	$email = $mybb->user['email'];

	eval("\$usertemplate = \"" . $templates->get('changeuserbox') . "\";");
}

if($mybb->settings['captchaimage'] && !$mybb->user['uid'])
{
	$form_captcha = new captcha(true, "post_captcha");
	$captcha = $form_captcha->html;
}

if($mybb->input['action'] == 'do_email' && $mybb->request_method == 'post')
{
	verify_post_check($mybb->input['my_post_key']);

	if(empty($name))
	{
		$errors[] = $lang->userdata_missing_username;
	}
	elseif(strpos($name, '<') !== false || strpos($name, '>') !== false || strpos($name, '&') !== false || my_strpos($name, '\\') !== false || strpos($name, ';') !== false || strpos($name, ',') !== false)
	{
		$errors[] = $lang->userdata_bad_characters_username;
	}

	if(empty($email))
	{
		$errors[] = $lang->userdata_missing_email;
	}
	elseif(!validate_email_format($email))
	{
		$errors[] = $lang->userdata_invalid_email_format;
	}

	if(empty($subject))
	{
		$errors[] = $lang->error_no_email_subject;
	}

	if(empty($message))
	{
		$errors[] = $lang->error_no_email_message;
	}

	if($mybb->settings['captchaimage'] && !$mybb->user['uid'])
	{
		if($form_captcha->validate_captcha() == false)
		{
			// CAPTCHA validation failed
			$errors[] = $lang->error_regimageinvalid;
		}
	}

	if(count($errors) == 0)
	{
		if($mybb->settings['mail_handler'] == 'smtp')
		{
			$from = $email;
		}
		else
		{
			$from = $name . ' <' . $email . '>';
		}
		my_mail($mybb->settings['adminemail'], '[' . $mybb->settings['bbname'] . ' ' . $pages['name'] . '] ' . $subject, $message, $from, '', '', false, 'text', '', $email);

		redirect($mybb->settings['bburl'], $lang->redirect_emailsent);
	}
	else
	{
		$errors = inline_error($errors);
	}
}

$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="' . $theme['borderwidth'] . '" cellpadding="' . $theme['tablespace'] . '" class="tborder">
<thead>
<tr>
<td colspan="2" class="thead">
<strong>' . $pages['name'] . '</strong>
</td>
</tr>
</thead>
<tbody>
{$usertemplate}
<tr>
<td width="40%" class="trow1"><strong>{$lang->email_subject}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="subject" value="{$subject}" /></td>
</tr>
<tr>
<td valign="top" width="40%" class="trow2"><strong>{$lang->email_message}</strong></td>
<td width="60%" class="trow2"><textarea cols="50" rows="10" name="message">{$message}</textarea></td>
</tr>
{$captcha}
</tbody>
</table>
<br />
<input type="hidden" name="action" value="do_email" />
<div align="center"><input type="submit" class="button" value="{$lang->send_email}" /></div>
</form>
{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>

Hope this will help technical persons to modify according to my forums..
Help me to get a plugin or a simple PHP file pls..
Quote:I got a PHP file ...
that file should be used with page manager plugin (see also share custom pages)

if you want to use it as a separate php file then copy that code in a text editor (eg. notepad++)

find below code near the top
global $headerinclude, $header, $theme, $footer, $templates, $lang;

add below code before above code in a new line
define (IN_MYBB,1);
require_once 'global.php';

it looks like below
define (IN_MYBB,1);
require_once 'global.php';
global $headerinclude, $header, $theme, $footer, $templates, $lang;
require_once MYBB_ROOT.'inc/class_captcha.php';

save the file as contactus.php. upload it to your MyBB forum files server where you have global.php and other php files

visit your forumURL/contactus.php

check if it works. and if you are satisfied then use its link on forum header or footer
Ya... Its visually good now...
But I didn get the mail.. That's the only problem now..
search
my_mail(, '[' . $mybb->settings['bbname'] . ' ' . $pages['name'] . '] ' . $subject, $message, $from, '', '', false, 'text', '', $email);
and replaceļ¼š
mail($mybb->settings['adminemail'], $subject, $message)
Sorry for my English
Ya.. Now I got the mail...
But its in SPAM folder since its a PHP mail...

How to change the code for SMTP mail ?
i need the page 2.
(2013-05-21, 12:26 PM)karlim Wrote: [ -> ]i need the page 2.

What page 2 ?!!
Cant get you Sad